Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-25 07:37:14
Exec Total Coverage
Lines: 1677 4282 39.2%
Functions: 129 333 38.7%
Branches: 920 2814 32.7%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "zc/saves.h"
37 #include "tiles.h"
38 #include "base/colors.h"
39 #include "pal.h"
40 #include "base/zsys.h"
41 #include "qst.h"
42 #include "zc/zc_sys.h"
43 #include "play_midi.h"
44 #include "jwin_a5.h"
45 #include "base/jwinfsel.h"
46 #include "base/gui.h"
47 #include "midi.h"
48 #include "subscr.h"
49 #include "zc/maps.h"
50 #include "sprite.h"
51 #include "zc/guys.h"
52 #include "zc/hero.h"
53 #include "zc/title.h"
54 #include "particles.h"
55 #include "zcmusic.h"
56 #include "zconsole.h"
57 #include "zc/ffscript.h"
58 #include "dialog/info.h"
59 #include "dialog/alert.h"
60 #include "zc/combos.h"
61 #include "zc/jit.h"
62 #include "zc/zc_subscr.h"
63 #include <fmt/format.h>
64 #include "zinfo.h"
65 #include "base/misctypes.h"
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern HeroClass Hero;
80 extern ZModule zcm;
81 extern zcmodule moduledata;
82 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
83 extern particle_list particles;
84 extern int32_t loadlast;
85 extern char *sfx_string[WAV_COUNT];
86 byte use_dwm_flush;
87 byte use_save_indicator;
88 int32_t paused_midi_pos = 0;
89 byte midi_suspended = 0;
90 byte zc_192b163_warp_compatibility;
91 char modulepath[2048];
92 bool epilepsyFlashReduction;
93 signed char pause_in_background_menu_init = 0;
94 byte pause_in_background = 0;
95 bool is_sys_pal = false;
96 static bool load_control_called_this_frame;
97 extern PALETTE* hw_palette;
98 extern bool update_hw_pal;
99 extern const char* dmaplist(int32_t index, int32_t* list_size);
100 int32_t getnumber(const char *prompt,int32_t initialval);
101
102 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
103 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
104 //extern byte refresh_select_screen;
105 //extern movingblock mblock2; //mblock[4]?
106 //extern int32_t db;
107
108 static const char *ZC_str = "ZQuest Classic";
109 #if defined(ALLEGRO_WINDOWS)
110 const char *qst_dir_name = "win_qst_dir";
111 static const char *qst_module_name = "current_module";
112 #elif defined(ALLEGRO_LINUX)
113 const char *qst_dir_name = "linux_qst_dir";
114 static const char *qst_module_name = "current_module";
115 #elif defined(__APPLE__)
116 const char *qst_dir_name = "osx_qst_dir";
117 static const char *qst_module_name = "current_module";
118 #endif
119 #ifdef ALLEGRO_LINUX
120 static const char *samplepath = "samplesoundset/patches.dat";
121 #endif
122 char qst_files_path[2048];
123
124 #ifdef _MSC_VER
125 #define getcwd _getcwd
126 #endif
127
128 bool rF11();
129 bool rI();
130 bool rQ();
131 bool zc_key_pressed();
132
133 #ifdef _WIN32
134
135 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
136 extern "C"
137 {
138 typedef HRESULT(WINAPI *t_DwmFlush)();
139 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
140 }
141
142 void do_DwmFlush()
143 {
144 static HMODULE shell = LoadLibrary("dwmapi.dll");
145
146 if(!shell)
147 return;
148
149 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
150 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
151
152 BOOL enabled;
153 isEnabled(&enabled);
154
155 if(isEnabled)
156 flush();
157 }
158
159 #endif // _WIN32
160
161 83751 bool flash_reduction_enabled(bool check_qr)
162 {
163
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
164 }
165
166 // Dialogue largening
167 void large_dialog(DIALOG *d)
168 {
169 large_dialog(d, 1.5);
170 }
171
172 void large_dialog(DIALOG *d, float RESIZE_AMT)
173 {
174 if(!d[0].d1)
175 {
176 d[0].d1 = 1;
177 int32_t oldwidth = d[0].w;
178 int32_t oldheight = d[0].h;
179 int32_t oldx = d[0].x;
180 int32_t oldy = d[0].y;
181 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
182 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
183 d[0].w = int32_t(d[0].w*RESIZE_AMT);
184 d[0].h = int32_t(d[0].h*RESIZE_AMT);
185
186 for(int32_t i=1; d[i].proc !=NULL; i++)
187 {
188 // Place elements horizontally
189 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
190 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
191
192 if(d[i].proc != d_stringloader)
193 {
194 if(d[i].proc==d_bitmap_proc)
195 {
196 d[i].w *= 2;
197 }
198 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
199 }
200
201 // Place elements vertically
202 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
203 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
204
205 // Vertically resize elements
206 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
207 {
208 d[i].h = int32_t((double)d[i].h*1.5);
209 }
210 else if(d[i].proc == jwin_droplist_proc)
211 {
212 d[i].y += int32_t((double)d[i].h*0.25);
213 d[i].h = int32_t((double)d[i].h*1.25);
214 }
215 else if(d[i].proc==d_bitmap_proc)
216 {
217 d[i].h *= 2;
218 }
219 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
220
221 // Fix frames
222 if(d[i].proc == jwin_frame_proc)
223 {
224 d[i].x++;
225 d[i].y++;
226 d[i].w-=4;
227 d[i].h-=4;
228 }
229 }
230 }
231
232 for(int32_t i=1; d[i].proc!=NULL; i++)
233 {
234 if(d[i].proc==jwin_slider_proc)
235 continue;
236
237 // Bigger font
238 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
239
240 if(!d[i].dp2 && bigfontproc)
241 {
242 d[i].dp2 = get_zc_font(font_lfont_l);
243 }
244 else if(!bigfontproc)
245 {
246 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
247 }
248
249 // Make checkboxes work
250 if(d[i].proc == jwin_check_proc)
251 d[i].proc = jwin_checkfont_proc;
252 else if(d[i].proc == jwin_radio_proc)
253 d[i].proc = jwin_radiofont_proc;
254 }
255
256 jwin_center_dialog(d);
257 }
258
259
260 /**********************************/
261 /******** System functions ********/
262 /**********************************/
263
264 static char cfg_sect[] = "zeldadx"; //We need to rename this.
265 static char ctrl_sect[] = "Controls";
266 static char sfx_sect[] = "Volume";
267
268 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
269 {
270 return D_O_K;
271 }
272
273 bool is_reserved_key(int c)
274 {
275 switch(c)
276 {
277 case KEY_ESC:
278 return true;
279 }
280 return false;
281 }
282 bool is_reserved_keycombo(int c, int modflag)
283 {
284 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
285 return true;
286 return false;
287 }
288 bool checkcheat(Cheat cheat)
289 {
290 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
291 return true; //Main key pressed
292 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
293 return true; //Alt key pressed
294 return false;
295 }
296 116 void load_default_cheatkeys()
297 {
298 116 memset(cheatkeys, 0, sizeof(cheatkeys));
299 116 cheatkeys[Cheat::Life][0] = KEY_H;
300 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
301 116 cheatkeys[Cheat::Magic][0] = KEY_M;
302 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
303 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
304 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
305 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
306 116 cheatkeys[Cheat::Clock][0] = KEY_I;
307 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
308 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
309 116 cheatkeys[Cheat::Light][0] = KEY_L;
310 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
311 116 cheatkeys[Cheat::Kill][0] = KEY_K;
312 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
313 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
314 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
315 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
316 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
317 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
318 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
319 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
320 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
321 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
322 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
323 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
324 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
325 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
326 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
327 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
328 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
329 116 }
330 116 void load_game_configs()
331 {
332 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
333 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
334 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
335 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
336 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
337 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
338 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
339 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
340 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
341 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
342 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
343 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
344 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
345 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
346 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
347
348 //cheat modifier keya
349 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
350 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
351 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
352 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
353
354 //cheat keys
355 116 load_default_cheatkeys();
356 char buf[256];
357
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 116 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
358 {
359
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
360 4060 std::string cheatname = cheat_to_string((Cheat)q);
361
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
362 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
363
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
366 4060 }
367
368
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
369 joystick_index = 0;
370
371 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
372 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
373 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
374 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
375 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
376 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
377 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
378 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
379 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
380 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
381
382 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
383 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
384 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
385 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
386
387 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
388 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
389 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
390 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
391 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
392 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
393 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
394 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
395 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
396 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
397 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
398
399 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
400 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
401 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
402 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
403
404 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
405
406 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
407 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
408 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
409 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
410 116 pan_style = zc_get_config(sfx_sect,"pan",1);
411 // 1 <= zcmusic_bufsz <= 128
412 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
413 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
414 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
415 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
416 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
417 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
418 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
419 #ifdef __EMSCRIPTEN__
420 if (em_is_mobile()) NameEntryMode = 2;
421 #endif
422 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
423 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
424 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
425 116 title_version = zc_get_config(cfg_sect,"title",2);
426 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
427 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
428
429 //default - scale x2, 640 x 480
430 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
431 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
432 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
433 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
434 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
435 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
436 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
437
438 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
439
440 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
441
442 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
443
444 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
445 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
446 #ifdef _WIN32
447 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
448 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
449 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
450 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
451
452 // This one's for Aero
453 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
454
455 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
456 #else //UNIX
457 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
458 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
459 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
460 #endif
461 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
462 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
463
464 116 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
465
466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(strlen(qstdir)==0)
467 {
468 116 getcwd(qstdir,2048);
469 116 fix_filename_case(qstdir);
470 116 fix_filename_slashes(qstdir);
471 116 put_backslash(qstdir);
472 116 }
473 else
474 {
475 chop_path(qstdir);
476 }
477
478 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
479 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
480 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
481 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
482 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
483 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
484 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
485 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
486 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
487 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
488 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
489 116 }
490
491 void save_control_configs(bool kb)
492 {
493 if(kb)
494 {
495 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
496 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
499
500 if (!replay_is_replaying())
501 {
502 zc_set_config(ctrl_sect,"key_a",Akey);
503 zc_set_config(ctrl_sect,"key_b",Bkey);
504 zc_set_config(ctrl_sect,"key_s",Skey);
505 zc_set_config(ctrl_sect,"key_l",Lkey);
506 zc_set_config(ctrl_sect,"key_r",Rkey);
507 zc_set_config(ctrl_sect,"key_p",Pkey);
508 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
509 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
510 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
511 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
512 zc_set_config(ctrl_sect,"key_up", DUkey);
513 zc_set_config(ctrl_sect,"key_down", DDkey);
514 zc_set_config(ctrl_sect,"key_left", DLkey);
515 zc_set_config(ctrl_sect,"key_right",DRkey);
516 }
517 }
518 else
519 {
520 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
521 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
522 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
523 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
524 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
525 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
526 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
527 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
528 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
529 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
530 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
531 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
532 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
533 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
534
535 zc_set_config(ctrl_sect,"btn_a",Abtn);
536 zc_set_config(ctrl_sect,"btn_b",Bbtn);
537 zc_set_config(ctrl_sect,"btn_s",Sbtn);
538 zc_set_config(ctrl_sect,"btn_m",Mbtn);
539 zc_set_config(ctrl_sect,"btn_l",Lbtn);
540 zc_set_config(ctrl_sect,"btn_r",Rbtn);
541 zc_set_config(ctrl_sect,"btn_p",Pbtn);
542 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
543 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
544 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
545 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
546
547 zc_set_config(ctrl_sect,"btn_up",DUbtn);
548 zc_set_config(ctrl_sect,"btn_down",DDbtn);
549 zc_set_config(ctrl_sect,"btn_left",DLbtn);
550 zc_set_config(ctrl_sect,"btn_right",DRbtn);
551 }
552 }
553
554 void save_cheatkeys()
555 {
556 char buf[256];
557 for(size_t q = 1; q < Cheat::Last; ++q)
558 {
559 if(!bindable_cheat((Cheat)q)) continue;
560 std::string cheatname = cheat_to_string((Cheat)q);
561 util::lowerstr(cheatname);
562 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
563 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
564 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
565 if(cheatkeys[q][1])
566 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
567 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
568 }
569 }
570
571 void save_game_configs()
572 {
573 packfile_password("");
574
575 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
576
577 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
578 {
579 int o_window_x, o_window_y;
580 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
581 zc_set_config(cfg_sect,"window_x",o_window_x);
582 zc_set_config(cfg_sect,"window_y",o_window_y);
583 }
584
585 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
586 {
587 double monitor_scale = zc_get_monitor_scale();
588 window_width = al_get_display_width(all_get_display()) / monitor_scale;
589 window_height = al_get_display_height(all_get_display()) / monitor_scale;
590 zc_set_config(cfg_sect,"window_width",window_width);
591 zc_set_config(cfg_sect,"window_height",window_height);
592 }
593
594 zc_set_config(cfg_sect,"load_last",loadlast);
595 chop_path(qstdir);
596 zc_set_config(cfg_sect,qst_dir_name,qstdir);
597 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
598
599 flush_config_file();
600 #ifdef __EMSCRIPTEN__
601 em_sync_fs();
602 #endif
603 }
604
605 //----------------------------------------------------------------
606
607 // Timers
608
609 29625 void fps_callback()
610 {
611 29625 lastfps=framecnt;
612 29625 dword tempsecs = fps_secs;
613 29625 ++tempsecs;
614 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
615 29625 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
616 29625 ++fps_secs;
617 29625 framecnt=0;
618 29625 }
619
620 END_OF_FUNCTION(fps_callback)
621
622 116 int32_t Z_init_timers()
623 {
624 static bool didit = false;
625 const static char *err_str = "Couldn't allocate timer";
626 116 err_str = err_str; //Unused variable warning
627
628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
629 return 1;
630
631 116 didit = true;
632
633 LOCK_VARIABLE(lastfps);
634 LOCK_VARIABLE(framecnt);
635 LOCK_FUNCTION(fps_callback);
636
637
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
638 return 0;
639
640 116 return 1;
641 116 }
642
643 void Z_remove_timers()
644 {
645 remove_int(fps_callback);
646 }
647
648 //----------------------------------------------------------------
649
650 void go()
651 {
652 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
653 }
654
655 void comeback()
656 {
657 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
658 }
659
660 void dump_pal(BITMAP *dest)
661 {
662 for(int32_t i=0; i<256; i++)
663 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
664 }
665
666 //----------------------------------------------------------------
667
668 int game_mouse_index = ZCM_BLANK;
669 static bool system_mouse = false;
670 28 bool sys_mouse()
671 {
672 28 system_mouse = true;
673 28 return MouseSprite::set(ZCM_NORMAL);
674 }
675 559 bool game_mouse()
676 {
677 559 system_mouse = false;
678 559 return MouseSprite::set(game_mouse_index);
679 }
680 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
681 {
682 if(!bmp)
683 return;
684 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
685 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
686 if(bmp->w == scaledw && bmp->h == scaledh)
687 user_scale = false;
688 if(user_scale || sys_recolor)
689 {
690 if(!user_scale) scale = 1;
691 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
692 if(user_scale)
693 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
694 else
695 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
696 if(sys_recolor)
697 recolor_mouse(tmpbmp);
698 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
699 destroy_bitmap(tmpbmp);
700 }
701 else
702 {
703 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
704 }
705 }
706
707 //Handles converting the mouse sprite from the .dat file
708 void recolor_mouse(BITMAP* bmp)
709 {
710 for(int32_t x = 0; x < bmp->w; ++x)
711 {
712 for(int32_t y = 0; y < bmp->h; ++y)
713 {
714 int32_t color = getpixel(bmp, x, y);
715 switch(color)
716 {
717 case dvc(1):
718 color = jwin_pal[jcCURSORMISC];
719 break;
720 case dvc(2):
721 color = jwin_pal[jcCURSOROUTLINE];
722 break;
723 case dvc(3):
724 color = jwin_pal[jcCURSORLIGHT];
725 break;
726 case dvc(5):
727 color = jwin_pal[jcCURSORDARK];
728 break;
729 default:
730 continue;
731 }
732 putpixel(bmp, x, y, color);
733 }
734 }
735 }
736 void load_mouse()
737 {
738 enter_sys_pal();
739 MouseSprite::set(-1);
740 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
741 int32_t sz = 16*scale;
742 for(int32_t j = 0; j < 1; ++j)
743 {
744 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
745 if(zcmouse[j])
746 destroy_bitmap(zcmouse[j]);
747 zcmouse[j] = create_bitmap_ex(8,sz,sz);
748 clear_bitmap(zcmouse[j]);
749 clear_bitmap(tmpbmp);
750 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
751 recolor_mouse(tmpbmp);
752 if(sz!=16)
753 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
754 else
755 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
756 destroy_bitmap(tmpbmp);
757 }
758 if(!hw_palette) hw_palette = &RAMpal;
759 zc_set_palette(*hw_palette);
760
761 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
762 clear_bitmap(blankmouse);
763
764 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
765 MouseSprite::assign(ZCM_BLANK, blankmouse);
766 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
767
768 //Reload the mouse
769 if(system_mouse)
770 sys_mouse();
771 else game_mouse();
772
773 destroy_bitmap(blankmouse);
774 exit_sys_pal();
775 }
776
777 // sets the video mode and initializes the palette and mouse sprite
778 116 bool game_vid_mode(int32_t mode,int32_t wait)
779 {
780
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
781 116 return true;
782
783 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
784 {
785 return false;
786 }
787
788 scrx = (resx-320)>>1;
789 scry = (resy-240)>>1;
790 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
791 zcmouse[q] = NULL;
792 load_mouse();
793
794 for(int32_t i=240; i<256; i++)
795 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
796
797 zc_set_palette(RAMpal);
798 clear_to_color(screen,BLACK);
799
800 rest(wait);
801 return true;
802 116 }
803
804 8 void null_quest()
805 {
806 char qstdat_string[2048];
807 8 strcpy(qstdat_string, "modules/classic/default.qst");
808
809 #ifdef __EMSCRIPTEN__
810 // The quest template data file is not included because it's really big and isn't really needed
811 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
812 // which is much smaller.
813 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
814 #endif
815
816 8 byte skip_flags[4] = { 0 };
817
818 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
819 8 }
820
821 8 void init_NES_mode()
822 {
823 8 null_quest();
824 8 }
825
826 //----------------------------------------------------------------
827
828 qword trianglelines[16]=
829 {
830 0x0000000000000000ULL,
831 0xFD00000000000000ULL,
832 0xFDFD000000000000ULL,
833 0xFDFDFD0000000000ULL,
834 0xFDFDFDFD00000000ULL,
835 0xFDFDFDFDFD000000ULL,
836 0xFDFDFDFDFDFD0000ULL,
837 0xFDFDFDFDFDFDFD00ULL,
838 0xFDFDFDFDFDFDFDFDULL,
839 0x00FDFDFDFDFDFDFDULL,
840 0x0000FDFDFDFDFDFDULL,
841 0x000000FDFDFDFDFDULL,
842 0x00000000FDFDFDFDULL,
843 0x0000000000FDFDFDULL,
844 0x000000000000FDFDULL,
845 0x00000000000000FDULL,
846 };
847
848 word screen_triangles[28][32];
849 /*
850 qword triangles[4][16]= //[direction][value]
851 {
852 {
853 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
854 },
855 {
856 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
857 },
858 {
859 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
860 },
861 {
862 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
863 }
864 };
865 */
866
867
868 /*
869 byte triangles[4][16][8]= //[direction][value][line]
870 {
871 {
872 {
873 0, 0, 0, 0, 0, 0, 0, 0
874 },
875 {
876 1, 0, 0, 0, 0, 0, 0, 0
877 },
878 {
879 2, 1, 0, 0, 0, 0, 0, 0
880 },
881 {
882 3, 2, 1, 0, 0, 0, 0, 0
883 },
884 {
885 4, 3, 2, 1, 0, 0, 0, 0
886 },
887 {
888 5, 4, 3, 2, 1, 0, 0, 0
889 },
890 {
891 6, 5, 4, 3, 2, 1, 0, 0
892 },
893 {
894 7, 6, 5, 4, 3, 2, 1, 0
895 },
896 {
897 8, 7, 6, 5, 4, 3, 2, 1
898 },
899 {
900 8, 8, 7, 6, 5, 4, 3, 2
901 },
902 {
903 8, 8, 8, 7, 6, 5, 4, 3
904 },
905 {
906 8, 8, 8, 8, 7, 6, 5, 4
907 },
908 {
909 8, 8, 8, 8, 8, 7, 6, 5
910 },
911 {
912 8, 8, 8, 8, 8, 8, 7, 6
913 },
914 {
915 8, 8, 8, 8, 8, 8, 8, 7
916 },
917 {
918 8, 8, 8, 8, 8, 8, 8, 8
919 }
920 },
921 {
922 {
923 0, 0, 0, 0, 0, 0, 0, 0
924 },
925 {
926 15, 0, 0, 0, 0, 0, 0, 0
927 },
928 {
929 14, 15, 0, 0, 0, 0, 0, 0
930 },
931 {
932 13, 14, 15, 0, 0, 0, 0, 0
933 },
934 {
935 12, 13, 14, 15, 0, 0, 0, 0
936 },
937 {
938 11, 12, 13, 14, 15, 0, 0, 0
939 },
940 {
941 10, 11, 12, 13, 14, 15, 0, 0
942 },
943 {
944 9, 10, 11, 12, 13, 14, 15, 0
945 },
946 {
947 8, 9, 10, 11, 12, 13, 14, 15
948 },
949 {
950 8, 8, 9, 10, 11, 12, 13, 14
951 },
952 {
953 8, 8, 8, 9, 10, 11, 12, 13
954 },
955 {
956 8, 8, 8, 8, 9, 10, 11, 12
957 },
958 {
959 8, 8, 8, 8, 8, 9, 10, 11
960 },
961 {
962 8, 8, 8, 8, 8, 8, 9, 10
963 },
964 {
965 8, 8, 8, 8, 8, 8, 8, 9
966 },
967 {
968 8, 8, 8, 8, 8, 8, 8, 8
969 }
970 },
971 {
972 {
973 0, 0, 0, 0, 0, 0, 0, 0
974 },
975 {
976 0, 0, 0, 0, 0, 0, 0, 1
977 },
978 {
979 0, 0, 0, 0, 0, 0, 1, 2
980 },
981 {
982 0, 0, 0, 0, 0, 1, 2, 3
983 },
984 {
985 0, 0, 0, 0, 1, 2, 3, 4
986 },
987 {
988 0, 0, 0, 1, 2, 3, 4, 5
989 },
990 {
991 0, 0, 1, 2, 3, 4, 5, 6
992 },
993 {
994 0, 1, 2, 3, 4, 5, 6, 7
995 },
996 {
997 1, 2, 3, 4, 5, 6, 7, 8
998 },
999 {
1000 2, 3, 4, 5, 6, 7, 8, 8
1001 },
1002 {
1003 3, 4, 5, 6, 7, 8, 8, 8
1004 },
1005 {
1006 4, 5, 6, 7, 8, 8, 8, 8
1007 },
1008 {
1009 5, 6, 7, 8, 8, 8, 8, 8
1010 },
1011 {
1012 6, 7, 8, 8, 8, 8, 8, 8
1013 },
1014 {
1015 7, 8, 8, 8, 8, 8, 8, 8
1016 },
1017 {
1018 8, 8, 8, 8, 8, 8, 8, 8
1019 }
1020 },
1021 {
1022 {
1023 0, 0, 0, 0, 0, 0, 0, 0
1024 },
1025 {
1026 0, 0, 0, 0, 0, 0, 0, 15
1027 },
1028 {
1029 0, 0, 0, 0, 0, 0, 15, 14
1030 },
1031 {
1032 0, 0, 0, 0, 0, 15, 14, 13
1033 },
1034 {
1035 0, 0, 0, 0, 15, 14, 13, 12
1036 },
1037 {
1038 0, 0, 0, 15, 14, 13, 12, 11
1039 },
1040 {
1041 0, 0, 15, 14, 13, 12, 11, 10
1042 },
1043 {
1044 0, 15, 14, 13, 12, 11, 10, 9
1045 },
1046 {
1047 15, 14, 13, 12, 11, 10, 9, 8
1048 },
1049 {
1050 14, 13, 12, 11, 10, 9, 8, 8
1051 },
1052 {
1053 13, 12, 11, 10, 9, 8, 8, 8
1054 },
1055 {
1056 12, 11, 10, 9, 8, 8, 8, 8
1057 },
1058 {
1059 11, 10, 9, 8, 8, 8, 8, 8
1060 },
1061 {
1062 10, 9, 8, 8, 8, 8, 8, 8
1063 },
1064 {
1065 9, 8, 8, 8, 8, 8, 8, 8
1066 },
1067 {
1068 8, 8, 8, 8, 8, 8, 8, 8
1069 }
1070 }
1071 };
1072 */
1073
1074
1075
1076 /*
1077 for (int32_t blockrow=0; blockrow<30; ++i)
1078 {
1079 for (int32_t linerow=0; linerow<8; ++i)
1080 {
1081 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1082 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1083 {
1084 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1085 ++triangleline;
1086 }
1087 }
1088 }
1089 */
1090
1091 // the ULL suffixes are to prevent this warning:
1092 // warning: integer constant is too large for "int32_t" type
1093
1094 qword triangles[4][16][8]= //[direction][value][line]
1095 {
1096 {
1097 {
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL,
1163 0xFD00000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL,
1173 0xFDFD000000000000ULL,
1174 0xFD00000000000000ULL,
1175 0x0000000000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL,
1183 0xFDFDFD0000000000ULL,
1184 0xFDFD000000000000ULL,
1185 0xFD00000000000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL,
1193 0xFDFDFDFD00000000ULL,
1194 0xFDFDFD0000000000ULL,
1195 0xFDFD000000000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL,
1203 0xFDFDFDFDFD000000ULL,
1204 0xFDFDFDFD00000000ULL,
1205 0xFDFDFD0000000000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL,
1213 0xFDFDFDFDFDFD0000ULL,
1214 0xFDFDFDFDFD000000ULL,
1215 0xFDFDFDFD00000000ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFD00ULL,
1224 0xFDFDFDFDFDFD0000ULL,
1225 0xFDFDFDFDFD000000ULL
1226 },
1227 {
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFD00ULL,
1235 0xFDFDFDFDFDFD0000ULL
1236 },
1237 {
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFD00ULL
1246 },
1247 {
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL
1256 }
1257 },
1258 {
1259 {
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL
1318 },
1319 {
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL,
1325 0x00000000000000FDULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL
1328 },
1329 {
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL,
1335 0x000000000000FDFDULL,
1336 0x00000000000000FDULL,
1337 0x0000000000000000ULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL,
1345 0x0000000000FDFDFDULL,
1346 0x000000000000FDFDULL,
1347 0x00000000000000FDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL,
1355 0x00000000FDFDFDFDULL,
1356 0x0000000000FDFDFDULL,
1357 0x000000000000FDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL,
1365 0x000000FDFDFDFDFDULL,
1366 0x00000000FDFDFDFDULL,
1367 0x0000000000FDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL,
1375 0x0000FDFDFDFDFDFDULL,
1376 0x000000FDFDFDFDFDULL,
1377 0x00000000FDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0x00FDFDFDFDFDFDFDULL,
1386 0x0000FDFDFDFDFDFDULL,
1387 0x000000FDFDFDFDFDULL
1388 },
1389 {
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0x00FDFDFDFDFDFDFDULL,
1397 0x0000FDFDFDFDFDFDULL
1398 },
1399 {
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0x00FDFDFDFDFDFDFDULL
1408 },
1409 {
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL
1418 }
1419 },
1420 {
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0xFD00000000000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0xFD00000000000000ULL,
1449 0xFDFD000000000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0xFD00000000000000ULL,
1458 0xFDFD000000000000ULL,
1459 0xFDFDFD0000000000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0xFD00000000000000ULL,
1467 0xFDFD000000000000ULL,
1468 0xFDFDFD0000000000ULL,
1469 0xFDFDFDFD00000000ULL
1470 },
1471 {
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0xFD00000000000000ULL,
1476 0xFDFD000000000000ULL,
1477 0xFDFDFD0000000000ULL,
1478 0xFDFDFDFD00000000ULL,
1479 0xFDFDFDFDFD000000ULL
1480 },
1481 {
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0xFD00000000000000ULL,
1485 0xFDFD000000000000ULL,
1486 0xFDFDFD0000000000ULL,
1487 0xFDFDFDFD00000000ULL,
1488 0xFDFDFDFDFD000000ULL,
1489 0xFDFDFDFDFDFD0000ULL
1490 },
1491 {
1492 0x0000000000000000ULL,
1493 0xFD00000000000000ULL,
1494 0xFDFD000000000000ULL,
1495 0xFDFDFD0000000000ULL,
1496 0xFDFDFDFD00000000ULL,
1497 0xFDFDFDFDFD000000ULL,
1498 0xFDFDFDFDFDFD0000ULL,
1499 0xFDFDFDFDFDFDFD00ULL
1500 },
1501 {
1502 0xFD00000000000000ULL,
1503 0xFDFD000000000000ULL,
1504 0xFDFDFD0000000000ULL,
1505 0xFDFDFDFD00000000ULL,
1506 0xFDFDFDFDFD000000ULL,
1507 0xFDFDFDFDFDFD0000ULL,
1508 0xFDFDFDFDFDFDFD00ULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFD000000000000ULL,
1513 0xFDFDFD0000000000ULL,
1514 0xFDFDFDFD00000000ULL,
1515 0xFDFDFDFDFD000000ULL,
1516 0xFDFDFDFDFDFD0000ULL,
1517 0xFDFDFDFDFDFDFD00ULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFD0000000000ULL,
1523 0xFDFDFDFD00000000ULL,
1524 0xFDFDFDFDFD000000ULL,
1525 0xFDFDFDFDFDFD0000ULL,
1526 0xFDFDFDFDFDFDFD00ULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFD00000000ULL,
1533 0xFDFDFDFDFD000000ULL,
1534 0xFDFDFDFDFDFD0000ULL,
1535 0xFDFDFDFDFDFDFD00ULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFD000000ULL,
1543 0xFDFDFDFDFDFD0000ULL,
1544 0xFDFDFDFDFDFDFD00ULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 },
1551 {
1552 0xFDFDFDFDFDFD0000ULL,
1553 0xFDFDFDFDFDFDFD00ULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL
1560 },
1561 {
1562 0xFDFDFDFDFDFDFD00ULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL
1570 },
1571 {
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL
1580 }
1581 },
1582 {
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x00000000000000FDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x00000000000000FDULL,
1611 0x000000000000FDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x00000000000000FDULL,
1620 0x000000000000FDFDULL,
1621 0x0000000000FDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x00000000000000FDULL,
1629 0x000000000000FDFDULL,
1630 0x0000000000FDFDFDULL,
1631 0x00000000FDFDFDFDULL
1632 },
1633 {
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x0000000000000000ULL,
1637 0x00000000000000FDULL,
1638 0x000000000000FDFDULL,
1639 0x0000000000FDFDFDULL,
1640 0x00000000FDFDFDFDULL,
1641 0x000000FDFDFDFDFDULL
1642 },
1643 {
1644 0x0000000000000000ULL,
1645 0x0000000000000000ULL,
1646 0x00000000000000FDULL,
1647 0x000000000000FDFDULL,
1648 0x0000000000FDFDFDULL,
1649 0x00000000FDFDFDFDULL,
1650 0x000000FDFDFDFDFDULL,
1651 0x0000FDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000000000ULL,
1655 0x00000000000000FDULL,
1656 0x000000000000FDFDULL,
1657 0x0000000000FDFDFDULL,
1658 0x00000000FDFDFDFDULL,
1659 0x000000FDFDFDFDFDULL,
1660 0x0000FDFDFDFDFDFDULL,
1661 0x00FDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000000000FDULL,
1665 0x000000000000FDFDULL,
1666 0x0000000000FDFDFDULL,
1667 0x00000000FDFDFDFDULL,
1668 0x000000FDFDFDFDFDULL,
1669 0x0000FDFDFDFDFDFDULL,
1670 0x00FDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000000000FDFDULL,
1675 0x0000000000FDFDFDULL,
1676 0x00000000FDFDFDFDULL,
1677 0x000000FDFDFDFDFDULL,
1678 0x0000FDFDFDFDFDFDULL,
1679 0x00FDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000000000FDFDFDULL,
1685 0x00000000FDFDFDFDULL,
1686 0x000000FDFDFDFDFDULL,
1687 0x0000FDFDFDFDFDFDULL,
1688 0x00FDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00000000FDFDFDFDULL,
1695 0x000000FDFDFDFDFDULL,
1696 0x0000FDFDFDFDFDFDULL,
1697 0x00FDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0x000000FDFDFDFDFDULL,
1705 0x0000FDFDFDFDFDFDULL,
1706 0x00FDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 },
1713 {
1714 0x0000FDFDFDFDFDFDULL,
1715 0x00FDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL
1722 },
1723 {
1724 0x00FDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL
1732 },
1733 {
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL
1742 }
1743 }
1744 };
1745
1746 int32_t black_opening_count=0;
1747 int32_t black_opening_x,black_opening_y;
1748 int32_t black_opening_shape;
1749
1750 1507 int32_t choose_opening_shape()
1751 {
1752 // First, count how many bits are set
1753 1507 int32_t numBits=0;
1754 int32_t bitCounter;
1755
1756
2/2
✓ Branch 0 taken 7535 times.
✓ Branch 1 taken 1507 times.
9042 for(int32_t i=0; i<bosMAX; i++)
1757 {
1758
2/2
✓ Branch 0 taken 5812 times.
✓ Branch 1 taken 1723 times.
7535 if(COOLSCROLL&(1<<i))
1759 1723 numBits++;
1760 7535 }
1761
1762 // Shouldn't happen...
1763
1/2
✓ Branch 0 taken 1507 times.
✗ Branch 1 not taken.
1507 if(numBits==0)
1764 return bosCIRCLE;
1765
1766 // Pick a bit
1767 1507 bitCounter=zc_rand()%numBits+1;
1768
1769
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 26 times.
2018 for(int32_t i=0; i<bosMAX; i++)
1770 {
1771 // If this bit is set, decrement the bit counter
1772
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1637 times.
1992 if(COOLSCROLL&(1<<i))
1773 1637 bitCounter--;
1774
1775 // When the counter hits 0, return a value based on
1776 // which bit it stopped on.
1777 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1778
2/2
✓ Branch 0 taken 1481 times.
✓ Branch 1 taken 511 times.
1992 if(bitCounter==0)
1779 1481 return i;
1780 511 }
1781
1782 // Shouldn't be necessary, but the compiler might complain, at least
1783 26 return bosCIRCLE;
1784 1507 }
1785
1786 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1787 {
1788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1789
1790 396 int32_t w=256, h=224;
1791 396 int32_t blockrows=28, blockcolumns=32;
1792 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1793
1794
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1795 {
1796
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1797 {
1798
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1799 354816 }
1800 11088 }
1801
1802 396 black_opening_count = 66;
1803 396 black_opening_x = x;
1804 396 black_opening_y = y;
1805 396 lensclk = 0;
1806 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1807
1808
1809
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1810 {
1811 refreshTints();
1812 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1813 }
1814
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1815 {
1816 FFCore.warpScriptCheck();
1817 for(int32_t i=0; i<66; i++)
1818 {
1819 draw_screen(tmpscr);
1820 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1821 advanceframe(true);
1822
1823 if(Quit)
1824 {
1825 break;
1826 }
1827 }
1828 }
1829 396 }
1830
1831 1111 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1832 {
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111 times.
1111 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1834
1835 1111 int32_t w=256, h=224;
1836 1111 int32_t blockrows=28, blockcolumns=32;
1837 1111 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1838
1839
2/2
✓ Branch 0 taken 31108 times.
✓ Branch 1 taken 1111 times.
32219 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1840 {
1841
2/2
✓ Branch 0 taken 995456 times.
✓ Branch 1 taken 31108 times.
1026564 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1842 {
1843
2/2
✓ Branch 0 taken 442711 times.
✓ Branch 1 taken 552745 times.
995456 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1844 995456 }
1845 31108 }
1846
1847 1111 black_opening_count = -66;
1848 1111 black_opening_x = x;
1849 1111 black_opening_y = y;
1850 1111 lensclk = 0;
1851
1/2
✓ Branch 0 taken 1111 times.
✗ Branch 1 not taken.
1111 if(black_opening_shape == bosFADEBLACK)
1852 {
1853 refreshTints();
1854 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1855 }
1856
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 912 times.
1111 if(wait)
1857 {
1858 912 FFCore.warpScriptCheck();
1859
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 60192 times.
61104 for(int32_t i=0; i<66; i++)
1860 {
1861 60192 draw_screen(tmpscr);
1862 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1863 60192 advanceframe(true);
1864
1865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60192 times.
60192 if(Quit)
1866 {
1867 break;
1868 }
1869 60192 }
1870 912 }
1871 1111 }
1872
1873 99462 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1874 {
1875 99462 clear_to_color(tmp_scr,BLACK);
1876 99462 int32_t w=256, h=224;
1877
1878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90288 times.
99462 switch(black_opening_shape)
1879 {
1880 case bosOVAL:
1881 {
1882 858 double new_w=(w/2)+abs(w/2-x);
1883 858 double new_h=(h/2)+abs(h/2-y);
1884 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1885 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1886 858 break;
1887 }
1888
1889 case bosTRIANGLE:
1890 {
1891 660 double new_w=(w/2)+abs(w/2-x);
1892 660 double new_h=(h/2)+abs(h/2-y);
1893 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1894 660 double P2= (PI/2);
1895 660 double P23=(2*PI/3);
1896 660 double P43=(4*PI/3);
1897 660 double Pa= (-4*PI*a/(3*max_a));
1898 660 double angle=P2+Pa;
1899 660 double a0=angle;
1900 660 double a2=angle+P23;
1901 660 double a4=angle+P43;
1902 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1903 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1904 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1905 0);
1906 660 break;
1907 }
1908
1909 case bosSMAS:
1910 {
1911
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1912
1913
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1914 {
1915
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1916 {
1917 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1918
1919
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1920 {
1921 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1922
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1923 54878208 [linerow];
1924 54878208 ++triangleline;
1925
1926
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1927 {
1928 6859776 }
1929 54878208 }
1930 1714944 }
1931 214368 }
1932
1933 7656 break;
1934 }
1935
1936 case bosFADEBLACK:
1937 {
1938 if(black_opening_count<0)
1939 {
1940 black_fade(zc_min(-black_opening_count,63));
1941 }
1942 else if(black_opening_count>0)
1943 {
1944 black_fade(63-zc_max(black_opening_count-3,0));
1945 }
1946 else black_fade(0);
1947 return; //no blitting from tmp_scr!
1948 }
1949
1950 90288 case bosCIRCLE:
1951 default:
1952 {
1953 90288 double new_w=(w/2)+abs(w/2-x);
1954 90288 double new_h=(h/2)+abs(h/2-y);
1955 90288 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1956 //circlefill(tmp_scr,x,y,a<<3,0);
1957 90288 circlefill(tmp_scr,x,y,r,0);
1958 90288 break;
1959 }
1960 }
1961
1962 99462 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1963 99462 }
1964
1965
1966 void black_fade(int32_t fadeamnt)
1967 {
1968 for(int32_t i=0; i < 0xEF; i++)
1969 {
1970 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1971 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1972 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1973 }
1974
1975 refreshpal = true;
1976 }
1977
1978 //----------------------------------------------------------------
1979
1980 44295676 bool item_disabled(int32_t item) //is this item disabled?
1981 {
1982
2/2
✓ Branch 0 taken 1738042 times.
✓ Branch 1 taken 42557634 times.
44295676 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1983 }
1984
1985 7617298 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1986 {
1987
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7482050 times.
7617298 if(current_item(item_type, true) >=item)
1988 {
1989 135248 return true;
1990 }
1991
1992 7482050 return false;
1993 7617298 }
1994
1995 31051365 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1996 {
1997
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053163 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16168740 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31051365 switch(item_type)
1998 {
1999 case itype_bomb:
2000 case itype_sbomb:
2001 {
2002 int32_t itemid = getItemID(itemsbuf, item_type, it);
2003
2004 if(itemid == -1)
2005 return false;
2006
2007 return (game->get_item(itemid));
2008 }
2009
2010 case itype_clock:
2011 {
2012 6053163 int32_t itemid = getItemID(itemsbuf, item_type, it);
2013
2014
2/4
✓ Branch 0 taken 6053163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053163 times.
✗ Branch 3 not taken.
6053163 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2015 return (game->get_item(itemid));
2016 6053163 return Hero.getClock()?1:0;
2017 }
2018
2019 case itype_key:
2020 return (game->get_keys()>0);
2021
2022 case itype_magiccontainer:
2023 return (game->get_maxmagic()>=game->get_mp_per_block());
2024
2025 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liTRIFORCE)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liTRIFORCE);
2044
2045 default:
2046
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2047 {
2048 3220277 return (game->lvlitems[it]&liTRIFORCE);
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_map: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 16168740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16168740 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liMAP)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liMAP)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 16168740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16168740 times.
16168740 if(it>=0&&it<MAXLEVELS)
2079 {
2080 16168740 return (game->lvlitems[it]&liMAP)!=0;
2081 }
2082
2083 break;
2084 }
2085
2086 return 0;
2087 }
2088
2089 case itype_compass: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liCOMPASS)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2111 {
2112 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2113 }
2114
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2121 {
2122
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2123 {
2124 case -2:
2125 {
2126 for(int32_t i=0; i<MAXLEVELS; i++)
2127 {
2128 if(game->lvlitems[i]&liBOSSKEY)
2129 {
2130 return true;
2131 }
2132 }
2133
2134 return false;
2135 }
2136
2137 case -1:
2138 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2139
2140 default:
2141
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2142 {
2143 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2144 }
2145 break;
2146 }
2147 return 0;
2148 }
2149
2150 default:
2151 //it=(1<<(it-1));
2152 /*if (item_type>=itype_max)
2153 {
2154 enter_sys_pal();
2155 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2156 exit_sys_pal();
2157
2158 return false;
2159 }*/
2160 int32_t itemid = getItemID(itemsbuf, item_type, it);
2161
2162 if(itemid == -1)
2163 return false;
2164
2165 return game->get_item(itemid);
2166 }
2167 31051365 }
2168
2169
2170 100009104 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2171 {
2172
9/9
✓ Branch 0 taken 6053163 times.
✓ Branch 1 taken 51583800 times.
✓ Branch 2 taken 6053163 times.
✓ Branch 3 taken 6053163 times.
✓ Branch 4 taken 6053163 times.
✓ Branch 5 taken 6053163 times.
✓ Branch 6 taken 6053163 times.
✓ Branch 7 taken 6053163 times.
✓ Branch 8 taken 6053163 times.
100009104 switch(item_type)
2173 {
2174 case itype_clock:
2175 {
2176 6053163 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2177
2178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6053163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6053163 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2179 return itemsbuf[maxid].fam_type;
2180
2181 6053163 return has_item(itype_clock,1) ? 1 : 0;
2182 }
2183
2184 case itype_key:
2185 6053163 return game->get_keys();
2186
2187 case itype_lkey:
2188 6053163 return game->lvlkeys[get_dlevel()];
2189
2190 case itype_magiccontainer:
2191 6053163 return game->get_maxmagic()/game->get_mp_per_block();
2192
2193 case itype_triforcepiece:
2194 {
2195 6053163 int32_t count=0;
2196
2197
2/2
✓ Branch 0 taken 3099219456 times.
✓ Branch 1 taken 6053163 times.
3105272619 for(int32_t i=0; i<MAXLEVELS; i++)
2198 {
2199 3099219456 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2200 3099219456 }
2201
2202 6053163 return count;
2203 }
2204
2205 case itype_map:
2206 {
2207 6053163 int32_t count=0;
2208
2209
2/2
✓ Branch 0 taken 3099219456 times.
✓ Branch 1 taken 6053163 times.
3105272619 for(int32_t i=0; i<MAXLEVELS; i++)
2210 {
2211 3099219456 count+=(game->lvlitems[i]&liMAP)?1:0;
2212 3099219456 }
2213
2214 6053163 return count;
2215 }
2216
2217 case itype_compass:
2218 {
2219 6053163 int32_t count=0;
2220
2221
2/2
✓ Branch 0 taken 3099219456 times.
✓ Branch 1 taken 6053163 times.
3105272619 for(int32_t i=0; i<MAXLEVELS; i++)
2222 {
2223 3099219456 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2224 3099219456 }
2225
2226 6053163 return count;
2227 }
2228
2229 case itype_bosskey:
2230 {
2231 6053163 int32_t count=0;
2232
2233
2/2
✓ Branch 0 taken 3099219456 times.
✓ Branch 1 taken 6053163 times.
3105272619 for(int32_t i=0; i<MAXLEVELS; i++)
2234 {
2235 3099219456 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2236 3099219456 }
2237
2238 6053163 return count;
2239 }
2240
2241 default:
2242 51583800 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2243
2244
2/2
✓ Branch 0 taken 9873870 times.
✓ Branch 1 taken 41709930 times.
51583800 if(maxid == -1)
2245 41709930 return 0;
2246
2247 9873870 return itemsbuf[maxid].fam_type;
2248 }
2249 100009104 }
2250
2251 92391806 int32_t current_item(int32_t item_type) //item currently being used
2252 {
2253 92391806 return current_item(item_type, true);
2254 }
2255
2256 116 std::map<int32_t, int32_t> itemcache;
2257 116 std::map<int32_t, int32_t> itemcache_cost;
2258
2259 void removeFromItemCache(int32_t itemclass)
2260 {
2261 itemcache.erase(itemclass);
2262 itemcache_cost.erase(itemclass);
2263 }
2264
2265 5857126 void flushItemCache(bool justcost)
2266 {
2267 5857126 itemcache_cost.clear();
2268
2/2
✓ Branch 0 taken 5827095 times.
✓ Branch 1 taken 30031 times.
5857126 if(!justcost)
2269 30031 itemcache.clear();
2270
2/2
✓ Branch 0 taken 5827029 times.
✓ Branch 1 taken 66 times.
5827095 else if(replay_version_check(0,19))
2271 5827029 return;
2272
2273 //also fix the active subscreen if items were deleted -DD
2274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30097 times.
30097 if(game != NULL)
2275 {
2276 30097 verifyBothWeapons();
2277 30097 refresh_subscr_items();
2278 30097 }
2279 5857126 }
2280
2281 // This is used often, so it should be as direct as possible.
2282 3376193741 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2283 {
2284 3376193741 bool use_cost_cache = replay_version_check(19);
2285
2/2
✓ Branch 0 taken 3300633740 times.
✓ Branch 1 taken 75560001 times.
3376193741 if(jinx_check)
2286 {
2287
4/4
✓ Branch 0 taken 47351661 times.
✓ Branch 1 taken 28208340 times.
✓ Branch 2 taken 8273869 times.
✓ Branch 3 taken 39077792 times.
75560001 if(!(HeroSwordClk() || HeroItemClk()))
2288 39077792 jinx_check = false; //not jinxed
2289 75560001 }
2290
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3375146295 times.
3376193741 if(!Hero.BunnyClock())
2291 3375146295 check_bunny = false; //not bunnied
2292
2/2
✓ Branch 0 taken 3346588150 times.
✓ Branch 1 taken 29605591 times.
3376193741 if(itemtype == itype_ring) checkmagic = true;
2293
4/4
✓ Branch 0 taken 3339711532 times.
✓ Branch 1 taken 36482209 times.
✓ Branch 2 taken 3309260890 times.
✓ Branch 3 taken 29262725 times.
6714717356 if (!jinx_check && !check_bunny
2294
3/4
✓ Branch 0 taken 3339711532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3338523615 times.
✓ Branch 3 taken 1187917 times.
3339711532 && (use_cost_cache || itemtype != itype_ring))
2295 {
2296
4/4
✓ Branch 0 taken 185275804 times.
✓ Branch 1 taken 3125173003 times.
✓ Branch 2 taken 185160767 times.
✓ Branch 3 taken 115037 times.
3310448807 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2297 3310448807 auto res = cache.find(itemtype);
2298
2299
2/2
✓ Branch 0 taken 3295120386 times.
✓ Branch 1 taken 15328421 times.
3310448807 if(res != cache.end())
2300 3295120386 return res->second;
2301 15328421 }
2302
2303 81073355 int32_t result = -1;
2304 81073355 int32_t highestlevel = -1;
2305
2306
2/2
✓ Branch 0 taken 20754778880 times.
✓ Branch 1 taken 81073355 times.
20835852235 for(int32_t i=0; i<MAXITEMS; i++)
2307 {
2308
5/6
✓ Branch 0 taken 1522459895 times.
✓ Branch 1 taken 19232318985 times.
✓ Branch 2 taken 21892796 times.
✓ Branch 3 taken 1500567099 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21892796 times.
20754778880 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2309 {
2310
4/4
✓ Branch 0 taken 20046522 times.
✓ Branch 1 taken 1846274 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20037828 times.
21892796 if(checkmagic && itemtype != itype_magicring)
2311
2/2
✓ Branch 0 taken 20037658 times.
✓ Branch 1 taken 170 times.
20037828 if(!checkmagiccost(i))
2312 170 continue;
2313
6/6
✓ Branch 0 taken 18598415 times.
✓ Branch 1 taken 3294211 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3051175 times.
✓ Branch 4 taken 1848085 times.
✓ Branch 5 taken 1446126 times.
21892626 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446126 times.
1446126 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2315 1446126 continue;
2316
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20446500 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20446500 if(check_bunny && !checkbunny(i))
2317 continue;
2318
2319
2/2
✓ Branch 0 taken 280132 times.
✓ Branch 1 taken 20166368 times.
20446500 if(itemsbuf[i].fam_type >= highestlevel)
2320 {
2321 20166368 highestlevel = itemsbuf[i].fam_type;
2322 20166368 result=i;
2323 20166368 }
2324 20446500 }
2325 20753332584 }
2326
2327
3/4
✓ Branch 0 taken 44591146 times.
✓ Branch 1 taken 36482209 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44591146 times.
81073355 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2328 {
2329
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 44589470 times.
44591146 if (use_cost_cache)
2330 {
2331
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 1080 times.
1676 if (!checkmagic)
2332 1080 itemcache[itemtype] = result;
2333
5/6
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 596 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1078 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
1676 if (checkmagic || result < 0 || checkmagiccost(result))
2334 1676 itemcache_cost[itemtype] = result;
2335 1676 }
2336 else
2337 {
2338 44589470 itemcache[itemtype] = result;
2339 }
2340 44591146 }
2341 81073355 return result;
2342 3376193741 }
2343
2344 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2345 3340155745 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2346 {
2347
2/4
✓ Branch 0 taken 3340155745 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3340155745 times.
3340155745 if(itype < 0 || itype >= itype_max) return -1;
2348
1/2
✓ Branch 0 taken 3340155745 times.
✗ Branch 1 not taken.
3340155745 if(game->OverrideItems[itype] > -2)
2349 {
2350 auto ovid = game->OverrideItems[itype];
2351 if(ovid < 0 || ovid >= MAXITEMS)
2352 return -1;
2353 if(itemsbuf[ovid].family == itype)
2354 {
2355 if(itype == itype_magicring)
2356 checkmagic = false;
2357 else if(itype == itype_ring)
2358 checkmagic = true;
2359
2360 if(checkmagic && !checkmagiccost(ovid))
2361 return -1;
2362 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2363 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2364 return -1;
2365 return ovid;
2366 }
2367 }
2368 3340155745 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2369
2/2
✓ Branch 0 taken 39522005 times.
✓ Branch 1 taken 3300633740 times.
3340155745 if(!jinx_check) //If not already a jinx-immune-only check...
2370 {
2371 //And the player IS jinxed...
2372
4/4
✓ Branch 0 taken 3272768377 times.
✓ Branch 1 taken 27865363 times.
✓ Branch 2 taken 8172633 times.
✓ Branch 3 taken 3264595744 times.
3300633740 if(HeroSwordClk() || HeroItemClk())
2373 {
2374 //Then do a jinx-immune-only check here
2375 36037996 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2376 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2377 //Should NOT need a compat rule, as this should always return -1 in old quests.
2378
2/2
✓ Branch 0 taken 1263260 times.
✓ Branch 1 taken 34774736 times.
36037996 if(ret2 > -1) return ret2;
2379 34774736 }
2380 3299370480 }
2381 3338892485 return ret;
2382 3340155745 }
2383
2384 19330871 int32_t current_item_power(int32_t itemtype)
2385 {
2386 19330871 int32_t result = current_item_id(itemtype,true);
2387
2/2
✓ Branch 0 taken 14038219 times.
✓ Branch 1 taken 5292652 times.
19330871 return (result<0) ? 0 : itemsbuf[result].power;
2388 }
2389
2390 11 int32_t heart_container_id()
2391 {
2392
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2393 {
2394
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2395 {
2396 11 return i;
2397 }
2398 308 }
2399 return -1;
2400 11 }
2401
2402 6053163 int32_t item_tile_mod()
2403 {
2404 6053163 int32_t tile=0;
2405
2406
2/2
✓ Branch 0 taken 1206152 times.
✓ Branch 1 taken 4847011 times.
6053163 if(game->get_bombs())
2407 {
2408 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2409
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2410 4681842 tile+=itemsbuf[itemid].ltm;
2411 4847011 }
2412
2413
2/2
✓ Branch 0 taken 4539087 times.
✓ Branch 1 taken 1514076 times.
6053163 if(game->get_sbombs())
2414 {
2415 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2416
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2417 1512648 tile+=itemsbuf[itemid].ltm;
2418 1514076 }
2419
2420
2/2
✓ Branch 0 taken 5943463 times.
✓ Branch 1 taken 109700 times.
6053163 if(current_item(itype_clock))
2421 {
2422 109700 int32_t itemid =
2423
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2424 ? iClock
2425 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2426
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2427 109700 tile+=itemsbuf[itemid].ltm;
2428 109700 }
2429
2430
2/2
✓ Branch 0 taken 4672422 times.
✓ Branch 1 taken 1380741 times.
6053163 if(current_item(itype_key))
2431 {
2432 1380741 int32_t itemid =
2433
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2434 ? iKey
2435 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2436
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2437 1380741 tile+=itemsbuf[itemid].ltm;
2438 1380741 }
2439
2440
2/2
✓ Branch 0 taken 5786060 times.
✓ Branch 1 taken 267103 times.
6053163 if(current_item(itype_lkey))
2441 {
2442 267103 int32_t itemid =
2443
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2444 ? iLevelKey
2445 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2446
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2447 267103 tile+=itemsbuf[itemid].ltm;
2448 267103 }
2449
2450
2/2
✓ Branch 0 taken 1256346 times.
✓ Branch 1 taken 4796817 times.
6053163 if(current_item(itype_map))
2451 {
2452 4796817 int32_t itemid =
2453
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2454 ? iMap
2455 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2456
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2457 4796817 tile+=itemsbuf[itemid].ltm;
2458 4796817 }
2459
2460
2/2
✓ Branch 0 taken 1234464 times.
✓ Branch 1 taken 4818699 times.
6053163 if(current_item(itype_compass))
2461 {
2462 4818699 int32_t itemid =
2463
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2464 ? iCompass
2465 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2466
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2467 4818699 tile+=itemsbuf[itemid].ltm;
2468 4818699 }
2469
2470
2/2
✓ Branch 0 taken 3422618 times.
✓ Branch 1 taken 2630545 times.
6053163 if(current_item(itype_bosskey))
2471 {
2472 2630545 int32_t itemid =
2473
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2474 ? iBossKey
2475 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2476
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2477 2630545 tile+=itemsbuf[itemid].ltm;
2478 2630545 }
2479
2480
2/2
✓ Branch 0 taken 2919187 times.
✓ Branch 1 taken 3133976 times.
6053163 if(current_item(itype_magiccontainer))
2481 {
2482 3133976 int32_t itemid =
2483
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2484 ? iMagicC
2485 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2486
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2487 3132106 tile+=itemsbuf[itemid].ltm;
2488 3133976 }
2489
2490
2/2
✓ Branch 0 taken 1592529 times.
✓ Branch 1 taken 4460634 times.
6053163 if(current_item(itype_triforcepiece))
2491 {
2492 4460634 int32_t itemid =
2493
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2494 ? iTriforce
2495 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2496
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2497 4460634 tile+=itemsbuf[itemid].ltm;
2498 4460634 }
2499
2500
2/2
✓ Branch 0 taken 6053163 times.
✓ Branch 1 taken 3099219456 times.
3105272619 for(int32_t i=0; i<itype_max; i++)
2501 {
2502
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56768000 times.
3099219456 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2503 {
2504
2/2
✓ Branch 0 taken 1108750 times.
✓ Branch 1 taken 55659250 times.
56768000 switch(i)
2505 {
2506 case itype_bomb:
2507 case itype_sbomb:
2508 case itype_clock:
2509 case itype_key:
2510 case itype_lkey:
2511 case itype_map:
2512 case itype_compass:
2513 case itype_bosskey:
2514 case itype_magiccontainer:
2515 case itype_triforcepiece:
2516 1108750 continue; //already handled
2517 }
2518 55659250 }
2519 3098110706 int32_t itemid = current_item_id(i,false);
2520
2/2
✓ Branch 0 taken 3092057543 times.
✓ Branch 1 taken 6053163 times.
3098110706 if(i == itype_shield)
2521 6053163 itemid = getCurrentShield(false);
2522
2523
4/4
✓ Branch 0 taken 80854968 times.
✓ Branch 1 taken 3017255738 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80753987 times.
3098110706 if(itemid < 0 || !checkbunny(itemid))
2524 3017356719 continue;
2525
2526 80753987 itemdata const& itm = itemsbuf[itemid];
2527
2528
2/2
✓ Branch 0 taken 75338158 times.
✓ Branch 1 taken 5415829 times.
80753987 switch(itm.family)
2529 {
2530 case itype_shield:
2531
1/2
✓ Branch 0 taken 5415829 times.
✗ Branch 1 not taken.
5415829 if(itm.flags & ITEM_FLAG9) //active shield
2532 {
2533 if(!usingActiveShield(itemid))
2534 {
2535 tile+=itm.misc6; //'Inactive PTM'
2536 continue;
2537 }
2538 }
2539 5415829 break;
2540 }
2541
2542 80753987 tile+=itm.ltm;
2543 80753987 }
2544
2545 6053163 return tile;
2546 }
2547
2548 6053163 int32_t bunny_tile_mod()
2549 {
2550
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6051293 times.
6053163 if(Hero.BunnyClock())
2551 {
2552 1870 return game->get_bunny_ltm();
2553 }
2554 6051293 return 0;
2555 6053163 }
2556
2557 // Hints are drawn on a separate layer to combo reveals.
2558 16332 void draw_lens_under(BITMAP *dest, bool layer)
2559 {
2560 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2561 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2562 //Lens flag 3: Don't show armos/chest/dive items
2563 //Lens flag 4: Show Raft Paths
2564 //Lens flag 5: Show Invisible Enemies
2565
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2566
2567 16332 int32_t strike_hint_table[11]=
2568 {
2569 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2570 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2571 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2572 };
2573
2574 // int32_t page = tmpscr->cpage;
2575 {
2576 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2577 // int32_t temptimer=0;
2578 16332 int32_t tempitem, tempweapon=0;
2579 16332 strike_hint=strike_hint_table[strike_hint_counter];
2580
2581
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2582 {
2583 490 strike_hint_timer=0;
2584 490 strike_hint_counter=((strike_hint_counter+1)%11);
2585 490 }
2586
2587 16332 ++strike_hint_timer;
2588
2589
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2590 {
2591 2874432 int32_t x = (i & 15) << 4;
2592 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2593 2874432 int32_t tempitemx=-16, tempitemy=-16;
2594 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2595
2596
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2597 {
2598 5748864 int32_t checkflag=0;
2599
2600
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2601 {
2602 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2603 2874432 }
2604 else
2605 {
2606 2874432 checkflag=tmpscr->sflag[i];
2607 }
2608
2609
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2610 {
2611
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2612 {
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2614 906 }
2615 else
2616 {
2617 192 checkflag = strike_hint;
2618 }
2619 1098 }
2620
2621
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2622 {
2623 case 0:
2624 case mfZELDA:
2625 case mfPUSHED:
2626 case mfENEMY0:
2627 case mfENEMY1:
2628 case mfENEMY2:
2629 case mfENEMY3:
2630 case mfENEMY4:
2631 case mfENEMY5:
2632 case mfENEMY6:
2633 case mfENEMY7:
2634 case mfENEMY8:
2635 case mfENEMY9:
2636 case mfSINGLE:
2637 case mfSINGLE16:
2638 case mfNOENEMY:
2639 case mfTRAP_H:
2640 case mfTRAP_V:
2641 case mfTRAP_4:
2642 case mfTRAP_LR:
2643 case mfTRAP_UD:
2644 case mfNOGROUNDENEMY:
2645 case mfNOBLOCKS:
2646 case mfSCRIPT1:
2647 case mfSCRIPT2:
2648 case mfSCRIPT3:
2649 case mfSCRIPT4:
2650 case mfSCRIPT5:
2651 case mfSCRIPT6:
2652 case mfSCRIPT7:
2653 case mfSCRIPT8:
2654 case mfSCRIPT9:
2655 case mfSCRIPT10:
2656 case mfSCRIPT11:
2657 case mfSCRIPT12:
2658 case mfSCRIPT13:
2659 case mfSCRIPT14:
2660 case mfSCRIPT15:
2661 case mfSCRIPT16:
2662 case mfSCRIPT17:
2663 case mfSCRIPT18:
2664 case mfSCRIPT19:
2665 case mfSCRIPT20:
2666 case mfPITHOLE:
2667 case mfPITFALLFLOOR:
2668 case mfLAVA:
2669 case mfICE:
2670 case mfICEDAMAGE:
2671 case mfDAMAGE1:
2672 case mfDAMAGE2:
2673 case mfDAMAGE4:
2674 case mfDAMAGE8:
2675 case mfDAMAGE16:
2676 case mfDAMAGE32:
2677 case mfFREEZEALL:
2678 case mfFREZEALLANSFFCS:
2679 case mfFREEZEFFCSOLY:
2680 case mfSCRITPTW1TRIG:
2681 case mfSCRITPTW2TRIG:
2682 case mfSCRITPTW3TRIG:
2683 case mfSCRITPTW4TRIG:
2684 case mfSCRITPTW5TRIG:
2685 case mfSCRITPTW6TRIG:
2686 case mfSCRITPTW7TRIG:
2687 case mfSCRITPTW8TRIG:
2688 case mfSCRITPTW9TRIG:
2689 case mfSCRITPTW10TRIG:
2690 case mfTROWEL:
2691 case mfTROWELNEXT:
2692 case mfTROWELSPECIALITEM:
2693 case mfSLASHPOT:
2694 case mfLIFTPOT:
2695 case mfLIFTORSLASH:
2696 case mfLIFTROCK:
2697 case mfLIFTROCKHEAVY:
2698 case mfDROPITEM:
2699 case mfSPECIALITEM:
2700 case mfDROPKEY:
2701 case mfDROPLKEY:
2702 case mfDROPCOMPASS:
2703 case mfDROPMAP:
2704 case mfDROPBOSSKEY:
2705 case mfSPAWNNPC:
2706 case mfSWITCHHOOK:
2707 case mfSIDEVIEWLADDER:
2708 case mfSIDEVIEWPLATFORM:
2709 case mfNOENEMYSPAWN:
2710 case mfENEMYALL:
2711 case mfNOMIRROR:
2712 case mfUNSAFEGROUND:
2713 case mf168:
2714 case mf169:
2715 case mf170:
2716 case mf171:
2717 case mf172:
2718 case mf173:
2719 case mf174:
2720 case mf175:
2721 case mf176:
2722 case mf177:
2723 case mf178:
2724 case mf179:
2725 case mf180:
2726 case mf181:
2727 case mf182:
2728 case mf183:
2729 case mf184:
2730 case mf185:
2731 case mf186:
2732 case mf187:
2733 case mf188:
2734 case mf189:
2735 case mf190:
2736 case mf191:
2737 case mf192:
2738 case mf193:
2739 case mf194:
2740 case mf195:
2741 case mf196:
2742 case mf197:
2743 case mf198:
2744 case mf199:
2745 case mf200:
2746 case mf201:
2747 case mf202:
2748 case mf203:
2749 case mf204:
2750 case mf205:
2751 case mf206:
2752 case mf207:
2753 case mf208:
2754 case mf209:
2755 case mf210:
2756 case mf211:
2757 case mf212:
2758 case mf213:
2759 case mf214:
2760 case mf215:
2761 case mf216:
2762 case mf217:
2763 case mf218:
2764 case mf219:
2765 case mf220:
2766 case mf221:
2767 case mf222:
2768 case mf223:
2769 case mf224:
2770 case mf225:
2771 case mf226:
2772 case mf227:
2773 case mf228:
2774 case mf229:
2775 case mf230:
2776 case mf231:
2777 case mf232:
2778 case mf233:
2779 case mf234:
2780 case mf235:
2781 case mf236:
2782 case mf237:
2783 case mf238:
2784 case mf239:
2785 case mf240:
2786 case mf241:
2787 case mf242:
2788 case mf243:
2789 case mf244:
2790 case mf245:
2791 case mf246:
2792 case mf247:
2793 case mf248:
2794 case mf249:
2795 case mf250:
2796 case mf251:
2797 case mf252:
2798 case mf253:
2799 case mf254:
2800 case mfEXTENDED:
2801 5706470 break;
2802
2803 case mfPUSHUD:
2804 case mfPUSHLR:
2805 case mfPUSH4:
2806 case mfPUSHU:
2807 case mfPUSHD:
2808 case mfPUSHL:
2809 case mfPUSHR:
2810 case mfPUSHUDNS:
2811 case mfPUSHLRNS:
2812 case mfPUSH4NS:
2813 case mfPUSHUNS:
2814 case mfPUSHDNS:
2815 case mfPUSHLNS:
2816 case mfPUSHRNS:
2817 case mfPUSHUDINS:
2818 case mfPUSHLRINS:
2819 case mfPUSH4INS:
2820 case mfPUSHUINS:
2821 case mfPUSHDINS:
2822 case mfPUSHLINS:
2823 case mfPUSHRINS:
2824
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2825
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2826 {
2827 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2828 }
2829
2830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2831
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2832 {
2833
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2834 {
2835
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2836 {
2837 case cPUSH_HEAVY:
2838 case cPUSH_HW:
2839 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2840 72 tempitemx=x, tempitemy=y;
2841
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2843 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2844
2845 72 break;
2846
2847 case cPUSH_HEAVY2:
2848 case cPUSH_HW2:
2849 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2850 63 tempitemx=x, tempitemy=y;
2851
2852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2853 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2854
2855 63 break;
2856 }
2857 1032 }
2858 2438 }
2859
2860 3148 break;
2861
2862 case mfWHISTLE:
2863
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2864 {
2865 tempitem=getItemID(itemsbuf,itype_whistle,1);
2866
2867 if(tempitem<0) break;
2868
2869 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2870 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2871 {
2872 tempitemx=x;
2873 tempitemy=y;
2874 }
2875
2876 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2877 }
2878
2879 2418 break;
2880
2881 //Why is this here?
2882 case mfFAIRY:
2883 case mfMAGICFAIRY:
2884 case mfALLFAIRY:
2885 if(hints)
2886 {
2887 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2888
2889 if(tempitem < 0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfANYFIRE:
2904
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2905 {
2906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2907 252 }
2908 else
2909 {
2910 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2911
2912
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2913
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 189 tempitemx=x;
2918 189 tempitemy=y;
2919 189 }
2920
2921 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 504 break;
2925
2926 case mfSTRONGFIRE:
2927 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2930 }
2931 else
2932 {
2933 tempitem=getItemID(itemsbuf,itype_candle,2);
2934
2935 if(tempitem<0) break;
2936
2937 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 tempitemx=x;
2941 tempitemy=y;
2942 }
2943
2944 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2945 }
2946
2947 break;
2948
2949 case mfMAGICFIRE:
2950 if(!hints)
2951 {
2952 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2953 }
2954 else
2955 {
2956 tempitem=getItemID(itemsbuf,itype_wand,1);
2957
2958 if(tempitem<0) break;
2959
2960 tempweapon=wFire;
2961
2962 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2963 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2964 {
2965 tempitemx=x;
2966 tempitemy=y;
2967 }
2968 else
2969 {
2970 tempweaponx=x;
2971 tempweapony=y;
2972 }
2973
2974 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2975 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2976 }
2977
2978 break;
2979
2980 case mfDIVINEFIRE:
2981 if(!hints)
2982 {
2983 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2984 }
2985 else
2986 {
2987 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2988
2989 if(tempitem<0) break;
2990
2991 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2992 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2993 {
2994 tempitemx=x;
2995 tempitemy=y;
2996 }
2997
2998 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2999 }
3000
3001 break;
3002
3003 case mfARROW:
3004
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3007 732 }
3008 else
3009 {
3010 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3011
3012
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3013
3014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3015
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3016 {
3017 61 tempitemx=x;
3018 61 tempitemy=y;
3019 61 }
3020
3021 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3022 }
3023
3024 814 break;
3025
3026 case mfSARROW:
3027 if(!hints)
3028 {
3029 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3030 }
3031 else
3032 {
3033 tempitem=getItemID(itemsbuf,itype_arrow,2);
3034
3035 if(tempitem<0) break;
3036
3037 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3038 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3039 {
3040 tempitemx=x;
3041 tempitemy=y;
3042 }
3043
3044 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3045 }
3046
3047 break;
3048
3049 case mfGARROW:
3050 if(!hints)
3051 {
3052 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3053 }
3054 else
3055 {
3056 tempitem=getItemID(itemsbuf,itype_arrow,3);
3057
3058 if(tempitem<0) break;
3059
3060 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3061 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3062 {
3063 tempitemx=x;
3064 tempitemy=y;
3065 }
3066
3067 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3068 }
3069
3070 break;
3071
3072 case mfBOMB:
3073
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3074 {
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3076 16 }
3077 else
3078 {
3079 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3080 17 tempweapon = wLitBomb;
3081
3082 //if (tempitem<0) break;
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3084
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3085 {
3086 12 tempweaponx=x;
3087 12 tempweapony=y;
3088 12 }
3089
3090 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3091 }
3092
3093 33 break;
3094
3095 case mfSBOMB:
3096
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3097 {
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3099 48 }
3100 else
3101 {
3102 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3103 //if (tempitem<0) break;
3104 48 tempweapon = wLitSBomb;
3105
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3107
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3108 {
3109 36 tempweaponx=x;
3110 36 tempweapony=y;
3111 36 }
3112
3113 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3114 }
3115
3116 96 break;
3117
3118 case mfARMOS_SECRET:
3119
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3120 {
3121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3122 12 }
3123 24 break;
3124
3125 case mfBRANG:
3126
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3129 }
3130 else
3131 {
3132 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3133
3134
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3135
3136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3137
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3138 {
3139 4 tempitemx=x;
3140 4 tempitemy=y;
3141 4 }
3142
3143 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3144 }
3145
3146 5 break;
3147
3148 case mfMBRANG:
3149 if(!hints)
3150 {
3151 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3152 }
3153 else
3154 {
3155 tempitem=getItemID(itemsbuf,itype_brang,2);
3156
3157 if(tempitem<0) break;
3158
3159 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3160 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3161 {
3162 tempitemx=x;
3163 tempitemy=y;
3164 }
3165
3166 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3167 }
3168
3169 break;
3170
3171 case mfFBRANG:
3172 if(!hints)
3173 {
3174 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3175 }
3176 else
3177 {
3178 tempitem=getItemID(itemsbuf,itype_brang,3);
3179
3180 if(tempitem<0) break;
3181
3182 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3183 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3184 {
3185 tempitemx=x;
3186 tempitemy=y;
3187 }
3188
3189 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3190 }
3191
3192 break;
3193
3194 case mfWANDMAGIC:
3195 if(!hints)
3196 {
3197 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3198 }
3199 else
3200 {
3201 tempitem=getItemID(itemsbuf,itype_wand,1);
3202
3203 if(tempitem<0) break;
3204
3205 tempweapon=itemsbuf[tempitem].wpn3;
3206
3207 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3208 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3209 {
3210 tempitemx=x;
3211 tempitemy=y;
3212 }
3213 else
3214 {
3215 tempweaponx=x;
3216 tempweapony=y;
3217 --lens_hint_weapon[wMagic][4];
3218
3219 if(lens_hint_weapon[wMagic][4]<-8)
3220 {
3221 lens_hint_weapon[wMagic][4]=8;
3222 }
3223 }
3224
3225 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3226 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3227 }
3228
3229 break;
3230
3231 case mfREFMAGIC:
3232
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3233 {
3234 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3235 }
3236 else
3237 {
3238 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3239
3240
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3241
3242 16 tempweapon=ewMagic;
3243
3244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3245
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3246 {
3247 13 tempitemx=x;
3248 13 tempitemy=y;
3249 13 }
3250 else
3251 {
3252 3 tempweaponx=x;
3253 3 tempweapony=y;
3254
3255
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3256 {
3257 1 --lens_hint_weapon[ewMagic][4];
3258 1 }
3259 else
3260 {
3261 2 ++lens_hint_weapon[ewMagic][4];
3262 }
3263
3264
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3265 {
3266 lens_hint_weapon[ewMagic][2]=up;
3267 }
3268
3269
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3270 {
3271 2 lens_hint_weapon[ewMagic][2]=down;
3272 2 }
3273 }
3274
3275 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3276 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3277 }
3278
3279 16 break;
3280
3281 case mfREFFIREBALL:
3282
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3283 {
3284 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3285 }
3286 else
3287 {
3288 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3289
3290
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3291
3292 16 tempweapon=ewFireball;
3293
3294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3295
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3296 {
3297 12 tempitemx=x;
3298 12 tempitemy=y;
3299 12 tempweaponx=x;
3300 12 tempweapony=y;
3301 12 ++lens_hint_weapon[ewFireball][3];
3302
3303
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3304 {
3305 1 lens_hint_weapon[ewFireball][3]=-8;
3306 1 lens_hint_weapon[ewFireball][4]=8;
3307 1 }
3308
3309
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3310 {
3311 8 ++lens_hint_weapon[ewFireball][4];
3312 8 }
3313 else
3314 {
3315 4 --lens_hint_weapon[ewFireball][4];
3316 }
3317 12 }
3318
3319 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3321 }
3322
3323 16 break;
3324
3325 case mfSWORD:
3326
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3327 {
3328 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3329 }
3330 else
3331 {
3332 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3333
3334
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3335
3336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3337
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3338 {
3339 5 tempitemx=x;
3340 5 tempitemy=y;
3341 5 }
3342
3343 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3344 }
3345
3346 7 break;
3347
3348 case mfWSWORD:
3349 if(!hints)
3350 {
3351 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3352 }
3353 else
3354 {
3355 tempitem=getItemID(itemsbuf,itype_sword,2);
3356
3357 if(tempitem<0) break;
3358
3359 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3360 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3361 {
3362 tempitemx=x;
3363 tempitemy=y;
3364 }
3365
3366 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3367 }
3368
3369 break;
3370
3371 case mfMSWORD:
3372 if(!hints)
3373 {
3374 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3375 }
3376 else
3377 {
3378 tempitem=getItemID(itemsbuf,itype_sword,3);
3379
3380 if(tempitem<0) break;
3381
3382 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3383 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3384 {
3385 tempitemx=x;
3386 tempitemy=y;
3387 }
3388
3389 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3390 }
3391
3392 break;
3393
3394 case mfXSWORD:
3395 if(!hints)
3396 {
3397 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3398 }
3399 else
3400 {
3401 tempitem=getItemID(itemsbuf,itype_sword,4);
3402
3403 if(tempitem<0) break;
3404
3405 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3406 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3407 {
3408 tempitemx=x;
3409 tempitemy=y;
3410 }
3411
3412 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3413 }
3414
3415 break;
3416
3417 case mfSWORDBEAM:
3418
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3419 {
3420 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3421 }
3422 else
3423 {
3424 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3425
3426
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3427
3428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3429
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3430 {
3431 11 tempitemx=x;
3432 11 tempitemy=y;
3433 11 }
3434
3435 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3436 }
3437
3438 16 break;
3439
3440 case mfWSWORDBEAM:
3441 if(!hints)
3442 {
3443 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3444 }
3445 else
3446 {
3447 tempitem=getItemID(itemsbuf,itype_sword,2);
3448
3449 if(tempitem<0) break;
3450
3451 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3452 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3453 {
3454 tempitemx=x;
3455 tempitemy=y;
3456 }
3457
3458 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3459 }
3460
3461 break;
3462
3463 case mfMSWORDBEAM:
3464 if(!hints)
3465 {
3466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3467 }
3468 else
3469 {
3470 tempitem=getItemID(itemsbuf,itype_sword,3);
3471
3472 if(tempitem<0) break;
3473
3474 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3475 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3476 {
3477 tempitemx=x;
3478 tempitemy=y;
3479 }
3480
3481 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3482 }
3483
3484 break;
3485
3486 case mfXSWORDBEAM:
3487 if(!hints)
3488 {
3489 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3490 }
3491 else
3492 {
3493 tempitem=getItemID(itemsbuf,itype_sword,4);
3494
3495 if(tempitem<0) break;
3496
3497 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3498 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3499 {
3500 tempitemx=x;
3501 tempitemy=y;
3502 }
3503
3504 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3505 }
3506
3507 break;
3508
3509 case mfHOOKSHOT:
3510
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3511 {
3512 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3513 }
3514 else
3515 {
3516 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3517
3518
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3519
3520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3521
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3522 {
3523 12 tempitemx=x;
3524 12 tempitemy=y;
3525 12 }
3526
3527 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3528 }
3529
3530 17 break;
3531
3532 case mfWAND:
3533
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3534 {
3535 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3536 }
3537 else
3538 {
3539 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3540
3541
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3542
3543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3544
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3545 {
3546 28 tempitemx=x;
3547 28 tempitemy=y;
3548 28 }
3549
3550 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3551 }
3552
3553 35 break;
3554
3555 case mfHAMMER:
3556
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3557 {
3558 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3559 }
3560 else
3561 {
3562 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3563
3564
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3565
3566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3567
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3568 {
3569 13 tempitemx=x;
3570 13 tempitemy=y;
3571 13 }
3572
3573 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3574 }
3575
3576 17 break;
3577
3578 case mfARMOS_ITEM:
3579 case mfDIVE_ITEM:
3580
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3581 {
3582 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3583 2064 }
3584 2064 break;
3585
3586 case 16:
3587 case 17:
3588 case 18:
3589 case 19:
3590 case 20:
3591 case 21:
3592 case 22:
3593 case 23:
3594 case 24:
3595 case 25:
3596 case 26:
3597 case 27:
3598 case 28:
3599 case 29:
3600 case 30:
3601 case 31:
3602
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3604 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3605
3606 3618 break;
3607 case mfSECRETSNEXT:
3608 if(!hints)
3609 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3610 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3611
3612 break;
3613
3614 case mfSTRIKE:
3615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3616 {
3617 906 goto special;
3618 }
3619 else
3620 {
3621 break;
3622 }
3623
3624 28640 default: goto special;
3625
3626 special:
3627
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3628 {
3629
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3630 {
3631 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3632 4913 }
3633 6549 }
3634
3635 29546 break;
3636 }
3637 5748864 }
3638 2874432 }
3639
3640
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3641 {
3642
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3643 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3644
3645
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3646 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3647
3648
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3649 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3650
3651
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3652 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3653
3654
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3655 {
3656 43 showbombeddoor(dest, 0);
3657 43 }
3658
3659
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3660 {
3661 39 showbombeddoor(dest, 1);
3662 39 }
3663
3664
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3665 {
3666 showbombeddoor(dest, 2);
3667 }
3668
3669
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3670 {
3671 37 showbombeddoor(dest, 3);
3672 37 }
3673 8166 }
3674
3675
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3676 {
3677
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3678 {
3679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3680 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3681 1123 }
3682 else
3683 {
3684
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3685 {
3686 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3687 48 int32_t tempitemx=-16;
3688 48 int32_t tempitemy=-16;
3689
3690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3691
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3692 {
3693 24 tempitemx=tmpscr->stairx;
3694 24 tempitemy=tmpscr->stairy+playing_field_offset;
3695 24 }
3696
3697 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3698 48 }
3699 }
3700 2034 }
3701 }
3702 16332 }
3703
3704 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3705
3706 7997 void draw_lens_over()
3707 {
3708 // Oh, what the heck.
3709 static BITMAP *lens_scr = NULL;
3710 static int32_t last_width = -1;
3711 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3712
3713 // Only redraw the circle if the size has changed
3714
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3715 {
3716
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3717 {
3718 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3719 10 }
3720
3721 10 clear_to_color(lens_scr, BLACK);
3722 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3723 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3724 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3725 10 last_width=width;
3726 10 }
3727
3728 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3729 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3730 7997 }
3731
3732 //----------------------------------------------------------------
3733
3734 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3735 {
3736 //recreating a big bitmap every frame is highly sluggish.
3737
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3738 31111 clear_to_color(wavebuf, BLACK);
3739 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3740
3741 int32_t ofs;
3742 // int32_t amplitude=8;
3743 // int32_t wavelength=4;
3744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3745
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3746 31111 int32_t amp2=168;
3747
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3748 31111 int32_t i=frame%amp2;
3749
3750
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3751 {
3752
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3753 {
3754 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3755 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3756 }
3757 else
3758 {
3759 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3760 }
3761
3762
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3763 {
3764
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3765 {
3766 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3767 1338021888 }
3768 5226648 }
3769 5226648 }
3770 31111 }
3771
3772 4848 void draw_fuzzy(int32_t fuzz)
3773 // draws from right half of scrollbuf to framebuf
3774 {
3775 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3776 byte *start, *si, *di;
3777
3778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3779 fuzz = 1;
3780
3781 4848 xstep = 128%fuzz;
3782
3783
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3784 3838 xstep = fuzz-xstep;
3785
3786 4848 ystep = 112%fuzz;
3787
3788
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3789 3434 ystep = fuzz-ystep;
3790
3791 4848 firsty = 1;
3792
3793
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3794 {
3795 174932 start = &(scrollbuf->line[y][256]);
3796
3797
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3798 {
3799 1085952 si = start;
3800 1085952 di = &(framebuf->line[y+dy][0]);
3801 1085952 i = xstep;
3802 1085952 firstx = 1;
3803
3804
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3805 {
3806 278003712 *(di++) = *si;
3807
3808
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3809 {
3810
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3811 42668864 si += fuzz;
3812 else
3813 {
3814 1085952 si += fuzz-xstep;
3815 1085952 firstx = 0;
3816 }
3817
3818 43754816 i = 0;
3819 43754816 }
3820 278003712 }
3821 1085952 }
3822
3823
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3824 170084 y += fuzz;
3825 else
3826 {
3827 4848 y += ystep;
3828 4848 ystep = fuzz;
3829 4848 firsty = 0;
3830 }
3831 }
3832 4848 }
3833
3834 9286600 void updatescr(bool allowwavy)
3835 {
3836
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286600 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3837
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9286600 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3838
3839
2/2
✓ Branch 0 taken 9259835 times.
✓ Branch 1 taken 26765 times.
9286600 if(toogam)
3840 {
3841 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3842 26765 }
3843
3844
1/2
✓ Branch 0 taken 9286600 times.
✗ Branch 1 not taken.
9286600 if(Showpal)
3845 dump_pal(framebuf);
3846
3847
2/2
✓ Branch 0 taken 8985368 times.
✓ Branch 1 taken 301232 times.
9286600 if(!Playing)
3848 301232 black_opening_count=0;
3849
3850
2/2
✓ Branch 0 taken 9213274 times.
✓ Branch 1 taken 73326 times.
9286600 if(black_opening_count<0) //shape is opening up
3851 {
3852 73326 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3853
3854
2/4
✓ Branch 0 taken 73326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73326 times.
73326 if(Advance||(!Paused))
3855 {
3856 73326 ++black_opening_count;
3857 73326 }
3858 73326 }
3859
2/2
✓ Branch 0 taken 9187138 times.
✓ Branch 1 taken 26136 times.
9213274 else if(black_opening_count>0) //shape is closing
3860 {
3861 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3862
3863
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3864 {
3865 26136 --black_opening_count;
3866 26136 }
3867 26136 }
3868
3869
3/4
✓ Branch 0 taken 9188645 times.
✓ Branch 1 taken 97955 times.
✓ Branch 2 taken 9188645 times.
✗ Branch 3 not taken.
9286600 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3870 {
3871 black_opening_shape = bosCIRCLE;
3872 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3873 refreshTints();
3874 refreshpal=true;
3875 }
3876
3877
2/2
✓ Branch 0 taken 9032399 times.
✓ Branch 1 taken 254201 times.
9286600 if(refreshpal)
3878 {
3879 254201 refreshpal=false;
3880 254201 RAMpal[253] = _RGB(0,0,0);
3881 254201 RAMpal[254] = _RGB(63,63,63);
3882 254201 hw_palette = &RAMpal;
3883 254201 update_hw_pal = true;
3884
3885 254201 create_rgb_table(&rgb_table, RAMpal, NULL);
3886 254201 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3887 254201 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3888
3889
2/2
✓ Branch 0 taken 65075456 times.
✓ Branch 1 taken 254201 times.
65329657 for(int32_t q=0; q<PAL_SIZE; q++)
3890 {
3891 65075456 trans_table2.data[0][q] = q;
3892 65075456 trans_table2.data[q][q] = q;
3893 65075456 }
3894 254201 }
3895
3896 9286600 bool clearwavy = (wavy <= 0);
3897
3898
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9278945 times.
9286600 if(wavy <= 0)
3899 {
3900 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3901 9278945 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3902 9278945 }
3903
3904 9286600 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3905
3906
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255239 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9286600 if(wavy && Playing && allowwavy)
3907 {
3908 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3909 31111 }
3910
3911
2/2
✓ Branch 0 taken 9278945 times.
✓ Branch 1 taken 7655 times.
9286600 if(clearwavy)
3912 9278945 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3913
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3914 7655 wavy--; // Wavy was set by a script. Decrement it.
3915
3916
5/6
✓ Branch 0 taken 8985368 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8725794 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9286600 if(Playing && msgpos && !screenscrolling)
3917 {
3918
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3919 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3920
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3921 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3922
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3923 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3924 259574 }
3925
3926 /*
3927 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3928 {
3929 BITMAP* subBmp = 0;
3930 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3931 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3932 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3933 destroy_bitmap(subBmp);
3934 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3935 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3936 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3937 }
3938 */
3939
3940
2/2
✓ Branch 0 taken 9245543 times.
✓ Branch 1 taken 41057 times.
9286600 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3941
3942
2/2
✓ Branch 0 taken 9250168 times.
✓ Branch 1 taken 36432 times.
9286600 if(nosubscr)
3943 {
3944 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3945 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3946 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3947 36432 }
3948
3949 //TODO: Optimize blit 'overcalls' -Gleeok
3950
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250168 times.
9286600 BITMAP *source = nosubscr ? panorama : wavybuf;
3951 9286600 blit(source,framebuf,0,0,0,0,256,224);
3952
3953 9286600 update_hw_screen();
3954 9286600 }
3955
3956 //----------------------------------------------------------------
3957
3958 static PALETTE syspal;
3959 int32_t onGUISnapshot()
3960 {
3961 char buf[200];
3962 int32_t num=0;
3963 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3964 do
3965 {
3966 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3967 }
3968 while(num<99999 && exists(buf));
3969
3970 BITMAP *b = create_bitmap_ex(8,resx,resy);
3971
3972 if(b)
3973 {
3974 blit(screen,b,0,0,0,0,resx,resy);
3975 save_bitmap(buf,b,RAMpal);
3976 destroy_bitmap(b);
3977 }
3978
3979 return D_O_K;
3980 }
3981
3982 int32_t onNonGUISnapshot()
3983 {
3984 PALETTE temppal;
3985 get_palette(temppal);
3986 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3987
3988 char buf[200];
3989 int32_t num=0;
3990
3991 do
3992 {
3993 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3994 }
3995 while(num<99999 && exists(buf));
3996
3997 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3998
3999 return D_O_K;
4000 }
4001
4002 int32_t onSnapshot()
4003 {
4004 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4005 {
4006 onGUISnapshot();
4007 }
4008 else
4009 {
4010 onNonGUISnapshot();
4011 }
4012
4013 return D_O_K;
4014 }
4015
4016 int32_t onSaveMapPic()
4017 {
4018 int32_t mapres2 = 0;
4019 char buf[200];
4020 int32_t num=0;
4021 mapscr tmpscr_b[2];
4022 mapscr tmpscr_c[6];
4023 BITMAP* _screen_draw_buffer = NULL;
4024 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4025 set_clip_state(_screen_draw_buffer,1);
4026
4027 for(int32_t i=0; i<6; ++i)
4028 {
4029 tmpscr_c[i] = tmpscr2[i];
4030 tmpscr2[i].zero_memory();
4031
4032 if(i>=2)
4033 {
4034 continue;
4035 }
4036
4037 tmpscr_b[i] = tmpscr[i];
4038 tmpscr[i].zero_memory();
4039 }
4040
4041 do
4042 {
4043 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4044 }
4045 while(num<99999 && exists(buf));
4046
4047 BITMAP* mappic = NULL;
4048
4049
4050 bool done=false, redraw=true;
4051
4052 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4053
4054 if(!mappic)
4055 {
4056 enter_sys_pal();
4057 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4058 exit_sys_pal();
4059 return D_O_K;;
4060 }
4061
4062 // draw the map
4063 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4064
4065 for(int32_t y=0; y<8; y++)
4066 {
4067 for(int32_t x=0; x<16; x++)
4068 {
4069 if(!displayOnMap(x, y))
4070 {
4071 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4072 }
4073 else
4074 {
4075 int32_t s = (y<<4) + x;
4076 loadscr2(1,s,-1);
4077
4078 for(int32_t i=0; i<6; i++)
4079 {
4080 if(tmpscr[1].layermap[i]<=0)
4081 continue;
4082
4083 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4084 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4085 {
4086 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4087
4088 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4089 }
4090 }
4091
4092 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4093
4094 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4095
4096 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4097 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4098
4099 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4100
4101 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4102 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4103 {
4104 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4105 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4106 {
4107 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4108 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4109 }
4110 }
4111 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4112
4113 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4114
4115 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4116 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4117 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4118 {
4119 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4120 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4121 }
4122 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4123 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4124
4125 }
4126
4127 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4128 }
4129 }
4130
4131 for(int32_t i=0; i<6; ++i)
4132 {
4133 tmpscr2[i]=tmpscr_c[i];
4134
4135 if(i>=2)
4136 {
4137 continue;
4138 }
4139
4140 tmpscr[i]=tmpscr_b[i];
4141 }
4142
4143 save_bitmap(buf,mappic,RAMpal);
4144 destroy_bitmap(mappic);
4145 destroy_bitmap(_screen_draw_buffer);
4146 return D_O_K;
4147 }
4148
4149 14 void f_Quit(int32_t type)
4150 {
4151
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4152 return;
4153
4154 14 bool from_menu = is_sys_pal;
4155
4156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4157 {
4158 14 music_pause();
4159 14 pause_all_sfx();
4160 14 sys_mouse();
4161 14 }
4162 14 enter_sys_pal();
4163 14 clear_keybuf();
4164
4165
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4166 13 replay_poll();
4167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4168 14 replay_peek_quit();
4169
4170
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4171 switch(type)
4172 {
4173 case qQUIT:
4174 onQuit();
4175 break;
4176
4177 case qRESET:
4178 onReset();
4179 break;
4180
4181 case qEXIT:
4182 onExit();
4183 break;
4184 }
4185
4186
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4187 {
4188 14 kill_sfx();
4189 14 music_stop();
4190 14 exit_sys_pal();
4191 14 update_hw_screen();
4192 14 }
4193 else
4194 {
4195 exit_sys_pal();
4196 if(!from_menu)
4197 {
4198 music_resume();
4199 resume_all_sfx();
4200 }
4201 }
4202
4203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4204 14 game_mouse();
4205 14 eat_buttons();
4206
4207 14 zc_readrawkey(KEY_ESC);
4208
4209 14 zc_readrawkey(KEY_ENTER);
4210 14 }
4211
4212 //----------------------------------------------------------------
4213
4214 int32_t onNoWalls()
4215 {
4216 cheats_enqueue(Cheat::Walls);
4217 return D_O_K;
4218 }
4219
4220 int32_t onIgnoreSideview()
4221 {
4222 cheats_enqueue(Cheat::IgnoreSideView);
4223 return D_O_K;
4224 }
4225
4226 9286474 int32_t input_idle(bool checkmouse)
4227 {
4228 static int32_t mx, my, mz, mb;
4229
4230
4/6
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461864 times.
✓ Branch 3 taken 6824610 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461864 times.
11748338 if(keypressed() || zc_key_pressed() ||
4231
4/8
✓ Branch 0 taken 2461864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461864 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461864 times.
✗ Branch 7 not taken.
2461864 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4232 {
4233 6824610 idle_count = 0;
4234
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6824610 times.
6824610 if(active_count < MAX_ACTIVE)
4236 {
4237 6824610 ++active_count;
4238 6824610 }
4239 6824610 }
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461864 times.
2461864 else if(idle_count < MAX_IDLE)
4241 {
4242 2461864 ++idle_count;
4243 2461864 active_count = 0;
4244 2461864 }
4245
4246 9286474 mx = mouse_x;
4247 9286474 my = mouse_y;
4248 9286474 mz = mouse_z;
4249 9286474 mb = mouse_b;
4250
4251 9286474 return idle_count;
4252 }
4253
4254 int32_t onGoFast()
4255 {
4256 cheats_enqueue(Cheat::Fast);
4257 return D_O_K;
4258 }
4259
4260 int32_t onKillCheat()
4261 {
4262 cheats_enqueue(Cheat::Kill);
4263 return D_O_K;
4264 }
4265
4266 int32_t onSecretsCheat()
4267 {
4268 cheats_enqueue(Cheat::TrigSecrets);
4269 return D_O_K;
4270 }
4271 int32_t onSecretsCheatPerm()
4272 {
4273 cheats_enqueue(Cheat::TrigSecretsPerm);
4274 return D_O_K;
4275 }
4276
4277 int32_t onShowLayer0()
4278 {
4279 show_layer_0 = !show_layer_0;
4280 return D_O_K;
4281 }
4282 int32_t onShowLayer1()
4283 {
4284 show_layer_1 = !show_layer_1;
4285 return D_O_K;
4286 }
4287 int32_t onShowLayer2()
4288 {
4289 show_layer_2 = !show_layer_2;
4290 return D_O_K;
4291 }
4292 int32_t onShowLayer3()
4293 {
4294 show_layer_3 = !show_layer_3;
4295 return D_O_K;
4296 }
4297 int32_t onShowLayer4()
4298 {
4299 show_layer_4 = !show_layer_4;
4300 return D_O_K;
4301 }
4302 int32_t onShowLayer5()
4303 {
4304 show_layer_5 = !show_layer_5;
4305 return D_O_K;
4306 }
4307 int32_t onShowLayer6()
4308 {
4309 show_layer_6 = !show_layer_6;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayerO()
4313 {
4314 show_layer_over=!show_layer_over;
4315 return D_O_K;
4316 }
4317 int32_t onShowLayerP()
4318 {
4319 show_layer_push=!show_layer_push;
4320 return D_O_K;
4321 }
4322 int32_t onShowLayerS()
4323 {
4324 show_sprites=!show_sprites;
4325 return D_O_K;
4326 }
4327 int32_t onShowLayerF()
4328 {
4329 show_ffcs=!show_ffcs;
4330 return D_O_K;
4331 }
4332 int32_t onShowLayerW()
4333 {
4334 show_walkflags=!show_walkflags;
4335 if(show_walkflags)
4336 show_effectflags = false;
4337 return D_O_K;
4338 }
4339 int32_t onShowLayerE()
4340 {
4341 show_effectflags=!show_effectflags;
4342 if(show_effectflags)
4343 show_walkflags = false;
4344 return D_O_K;
4345 }
4346 int32_t onShowFFScripts()
4347 {
4348 show_ff_scripts=!show_ff_scripts;
4349 return D_O_K;
4350 }
4351 int32_t onShowHitboxes()
4352 {
4353 show_hitboxes=!show_hitboxes;
4354 return D_O_K;
4355 }
4356 int32_t onShowInfoOpacity()
4357 {
4358 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4359 zc_set_config("zc","debug_info_opacity",info_opacity);
4360 return D_O_K;
4361 }
4362
4363 int32_t onLightSwitch()
4364 {
4365 cheats_enqueue(Cheat::Light);
4366 return D_O_K;
4367 }
4368
4369 int32_t onGoTo();
4370 int32_t onGoToComplete();
4371
4372 9286474 void syskeys()
4373 {
4374 9286474 update_system_keys();
4375
4376 int32_t oldtitle_version;
4377
4378
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(close_button_quit)
4379 {
4380 close_button_quit=false;
4381 f_Quit(qEXIT);
4382 }
4383
4384 9286474 poll_joystick();
4385
4386
2/10
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9286474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9286474 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4387 {
4388 oldtitle_version=title_version;
4389 System();
4390 }
4391
4392 9286474 mouse_down=gui_mouse_b();
4393
4394
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(zc_read_system_key(KEY_F1))
4395 {
4396 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4397 {
4398 halt=!halt;
4399 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4400 }
4401 else
4402 {
4403 Throttlefps=!Throttlefps;
4404 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4405 }
4406 }
4407
4408 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4409 /*
4410 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4411 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4412 */
4413
4414
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(zc_read_system_key(KEY_F2))
4415 {
4416 ShowFPS=!ShowFPS;
4417 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4418 }
4419
4420
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286474 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4421
4422
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286474 if(zc_read_system_key(KEY_F4) && Playing)
4423 {
4424 Paused=true;
4425 Advance=true;
4426 }
4427
4428
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(zc_read_system_key(KEY_F6)) onTryQuit();
4429
4430 #ifndef ALLEGRO_MACOSX
4431
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4432
4433
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4434 #else
4435 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4436
4437 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4438 #endif
4439
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9286474 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4440
4441
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if (zc_read_system_key(KEY_F12))
4442 {
4443 onSnapshot();
4444 }
4445
4446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286474 if(debug_enabled && zc_read_system_key(KEY_TAB))
4447 set_debug(!get_debug());
4448
4449
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(CheatModifierKeys())
4450 {
4451 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4452 {
4453 if(!bindable_cheat(c))
4454 continue;
4455 if(get_debug() || cheat >= cheat_lvl(c))
4456 {
4457 if(checkcheat(c))
4458 cheats_hit_bind(c);
4459 }
4460 }
4461 }
4462
4463
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(volkeys)
4464 {
4465 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4466
4467 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4468
4469 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4470
4471 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4472 }
4473
4474
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9286474 if(!get_debug() || !SystemKeys || replay_is_replaying())
4475 9286474 goto bottom;
4476
4477 if(zc_readkey(KEY_D))
4478 {
4479 details = !details;
4480 rectfill(screen,0,0,319,7,BLACK);
4481 rectfill(screen,0,8,31,239,BLACK);
4482 rectfill(screen,288,8,319,239,BLACK);
4483 rectfill(screen,32,232,287,239,BLACK);
4484 }
4485
4486 if(zc_readkey(KEY_P)) Paused=!Paused;
4487
4488 //if(zc_readkey(KEY_P)) centerHero();
4489 if(zc_readkey(KEY_A))
4490 {
4491 Paused=true;
4492 Advance=true;
4493 }
4494
4495 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4496 #ifndef ALLEGRO_MACOSX
4497 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4498
4499 if(zc_readkey(KEY_F7))
4500 {
4501 Matrix(ss_speed, ss_density, 0);
4502 game_pal();
4503 }
4504 #else
4505 // The reason these are different on Mac in the first place is that
4506 // the OS doesn't let us use F9 and F10...
4507 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4508
4509 if(zc_readkey(KEY_F9))
4510 {
4511 Matrix(ss_speed, ss_density, 0);
4512 game_pal();
4513 }
4514 #endif
4515 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4516 {
4517 //change containers
4518 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4519 {
4520 //magic containers
4521 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4522 {
4523 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4524 }
4525 else
4526 {
4527 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4528 }
4529 }
4530 else
4531 {
4532 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4533 {
4534 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4535 }
4536 else
4537 {
4538 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4539 }
4540 }
4541 }
4542
4543 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4544 {
4545 //change containers
4546 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4547 {
4548 //magic containers
4549 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4550 {
4551 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4552 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4553 //heart containers
4554 }
4555 else
4556 {
4557 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4558 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4559 }
4560 }
4561 else
4562 {
4563 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4564 {
4565 game->set_magic(zc_max(game->get_magic()-1,0));
4566 }
4567 else
4568 {
4569 game->set_life(zc_max(game->get_life()-1,0));
4570 }
4571 }
4572 }
4573
4574 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4575
4576 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4577
4578 verifyBothWeapons();
4579
4580 bottom:
4581
4582
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(input_idle(true) > after_time())
4583 {
4584 Matrix(ss_speed, ss_density, 0);
4585 game_pal();
4586 }
4587 9286474 }
4588
4589 708302 void checkQuitKeys()
4590 {
4591 #ifndef ALLEGRO_MACOSX
4592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708302 times.
708302 if(key[KEY_F9]) f_Quit(qRESET);
4593
4594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708302 times.
708302 if(key[KEY_F10]) f_Quit(qEXIT);
4595 #else
4596 if(key[KEY_F7]) f_Quit(qRESET);
4597
4598 if(key[KEY_F8]) f_Quit(qEXIT);
4599 #endif
4600 708302 }
4601
4602 9286474 bool CheatModifierKeys()
4603 {
4604 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4605 // to trigger cheats.
4606
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if (replay_is_replaying())
4607 9286474 return false;
4608
4609 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4610 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4611 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4612 {
4613 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4614 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4615 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4616 {
4617 return true;
4618 }
4619 }
4620 return false;
4621 9286474 }
4622
4623 //99:05:54, for some reason?
4624 #define OLDMAXTIME 21405240
4625 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4626 #define MAXTIME 1944000000
4627
4628 9286600 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4629 {
4630
2/2
✓ Branch 0 taken 9166477 times.
✓ Branch 1 taken 120123 times.
9286600 if(zcmusic!=NULL)
4631 {
4632 120123 zcmusic_poll();
4633 120123 }
4634 9286600 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4635
4636 9286600 updatescr(allowwavy);
4637
4638 9286600 Advance=false;
4639
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9286600 times.
9286600 while(Paused && !Advance && !Quit)
4640 {
4641 // have to call this, otherwise we'll get an infinite loop
4642 syskeys();
4643 if(allowF6Script)
4644 {
4645 FFCore.runF6Engine();
4646 }
4647 throttleFPS();
4648
4649 #ifdef _WIN32
4650
4651 if(use_dwm_flush)
4652 {
4653 do_DwmFlush();
4654 }
4655
4656 #endif
4657
4658 // to keep music playing
4659 if(zcmusic!=NULL)
4660 {
4661 zcmusic_poll();
4662 }
4663
4664 update_hw_screen();
4665 }
4666
4667
2/2
✓ Branch 0 taken 9286488 times.
✓ Branch 1 taken 112 times.
9286600 if(Quit)
4668 112 return;
4669
4670
3/4
✓ Branch 0 taken 8985359 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8985359 times.
9286488 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4671 8985359 game->change_time(1);
4672
4673 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4674
4675 9286488 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4676
2/2
✓ Branch 0 taken 19691 times.
✓ Branch 1 taken 9266797 times.
9286488 if (replay_version_check(0, 16))
4677 9266797 should_reset_down_state = replay_version_check(11, 16);
4678
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2336808 times.
9286488 if (should_reset_down_state)
4679 {
4680
2/2
✓ Branch 0 taken 42062544 times.
✓ Branch 1 taken 2336808 times.
44399352 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4681 42062544 down_control_states[i] = raw_control_state[i];
4682 2336808 }
4683
4684
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286474 times.
9286488 if (replay_is_active())
4685 {
4686
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016025 times.
9286474 if (replay_version_check(3))
4687 8016025 replay_poll();
4688
4689
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2340376 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9286474 if (replay_version_check(11) || replay_version_check(6, 8))
4690 2440911 replay_peek_input();
4691 9286474 }
4692
4693 9286488 load_control_called_this_frame = false;
4694
4695 9286488 poll_keyboard();
4696 9286488 update_keys();
4697
4698 9286488 ++frame;
4699
4700
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286474 times.
9286488 if (replay_is_replaying())
4701 9286474 replay_do_cheats();
4702 9286488 syskeys();
4703
4704 // The mouse variables can change from the mouse thread at anytime during a frame,
4705 // so save the result at the start so that replaying is consistent.
4706 9286488 script_mouse_x = gui_mouse_x();
4707 9286488 script_mouse_y = gui_mouse_y();
4708 9286488 script_mouse_z = mouse_z;
4709 9286488 script_mouse_b = mouse_b;
4710
4711 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4712 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4713 // approach here means it doesn't matter which call adds the cheat.
4714 9286488 cheats_execute_queued();
4715
4716
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286474 times.
9286488 if (replay_is_replaying())
4717 9286474 replay_peek_quit();
4718
2/2
✓ Branch 0 taken 9286474 times.
✓ Branch 1 taken 14 times.
9286488 if (GameFlags & GAMEFLAG_TRYQUIT)
4719 14 replay_step_quit(0);
4720
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9283554 times.
9286488 if(allowF6Script)
4721 9283554 FFCore.runF6Engine();
4722
2/2
✓ Branch 0 taken 9286188 times.
✓ Branch 1 taken 300 times.
9286488 if (Quit)
4723 300 replay_step_quit(Quit);
4724 // Someday... maybe install a Turbo button here?
4725 9286488 throttleFPS();
4726
4727 #ifdef _WIN32
4728
4729 if(use_dwm_flush)
4730 {
4731 do_DwmFlush();
4732 }
4733
4734 #endif
4735
4736 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4737
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9217730 times.
9286488 if(sfxcleanup)
4738 9217730 sfx_cleanup();
4739
4740 9286488 jit_poll();
4741
4742 #ifdef __EMSCRIPTEN__
4743 // Yield the main thread back to the browser occasionally.
4744 if (is_headless())
4745 {
4746 static int rate = 10000;
4747 static int force_yield = rate;
4748 if (force_yield++ >= rate)
4749 {
4750 force_yield = 0;
4751 emscripten_sleep(0);
4752 }
4753 }
4754 #endif
4755 9286600 }
4756
4757 101 void zapout()
4758 {
4759 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4760 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4761
4762 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4763 101 script_drawing_commands.Clear();
4764
4765 // zap out
4766
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4767 {
4768 2424 draw_fuzzy(i);
4769 2424 advanceframe(true);
4770
4771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4772 {
4773 break;
4774 }
4775 2424 }
4776 101 }
4777
4778 101 void zapin()
4779 {
4780 101 FFCore.warpScriptCheck();
4781 101 draw_screen(tmpscr);
4782 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4783 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4784 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4785
4786 // zap out
4787 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4788
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4789 {
4790 2424 draw_fuzzy(i);
4791 2424 advanceframe(true);
4792
4793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4794 {
4795 break;
4796 }
4797 2424 }
4798 101 }
4799
4800
4801 65 void wavyout(bool showhero)
4802 {
4803 65 draw_screen(tmpscr, showhero);
4804 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4805
4806 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4807 65 clear_to_color(wavebuf,0);
4808 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4809
4810 static PALETTE wavepal;
4811
4812 int32_t ofs;
4813 65 int32_t amplitude=8;
4814
4815 65 int32_t wavelength=4;
4816 65 double palpos=0, palstep=4, palstop=126;
4817
4818 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4819
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4820 {
4821
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4822 {
4823 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4824 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4825 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4826 698880 }
4827
4828 2730 palpos+=palstep;
4829
4830
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4831 {
4832 2730 hw_palette = &wavepal;
4833 2730 update_hw_pal = true;
4834 2730 }
4835 else
4836 {
4837 hw_palette = &RAMpal;
4838 update_hw_pal = true;
4839 }
4840
4841
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4842 {
4843
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4844 {
4845 117411840 ofs=0;
4846
4847
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4848 {
4849 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4850 28654080 }
4851
4852 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4853 117411840 }
4854 458640 }
4855
4856 2730 advanceframe(true);
4857
4858 // animate_combos();
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4860 break;
4861 2730 }
4862
4863 65 destroy_bitmap(wavebuf);
4864 65 }
4865
4866 65 void wavyin()
4867 {
4868 65 draw_screen(tmpscr);
4869 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4870
4871 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4872 65 clear_to_color(wavebuf,0);
4873 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4874
4875 static PALETTE wavepal;
4876
4877 //Breaks dark rooms.
4878 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4879 /*
4880 loadfullpal();
4881 loadlvlpal(DMaps[currdmap].color);
4882 ringcolor(false);
4883 */
4884 65 refreshpal=false;
4885 int32_t ofs;
4886 65 int32_t amplitude=8;
4887 65 int32_t wavelength=4;
4888 65 double palpos=168, palstep=4, palstop=126;
4889
4890 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4891
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4892 {
4893
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4894 {
4895 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4896 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4897 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4898 698880 }
4899
4900 2730 palpos-=palstep;
4901
4902
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4903 {
4904 2730 hw_palette = &wavepal;
4905 2730 update_hw_pal = true;
4906 2730 }
4907 else
4908 {
4909 hw_palette = &RAMpal;
4910 update_hw_pal = true;
4911 }
4912
4913
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4914 {
4915
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4916 {
4917 117411840 ofs=0;
4918
4919
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4920 {
4921 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4922 29352960 }
4923
4924 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4925 117411840 }
4926 458640 }
4927
4928 2730 advanceframe(true);
4929 // animate_combos();
4930
4931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4932 break;
4933 2730 }
4934
4935 65 destroy_bitmap(wavebuf);
4936 65 }
4937
4938 2168 void blackscr(int32_t fcnt,bool showsubscr)
4939 {
4940 2168 reset_pal_cycling();
4941 2168 script_drawing_commands.Clear();
4942
4943 2168 FFCore.warpScriptCheck();
4944 2168 bool showtime = game->should_show_time();
4945
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4946 {
4947 64970 clear_bitmap(framebuf);
4948
4949
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4950 {
4951 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4952
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4953 {
4954 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4955 750 }
4956 39890 }
4957
4958 64970 advanceframe(true);
4959
4960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4961 break;
4962
4963 64970 --fcnt;
4964 }
4965 2168 }
4966
4967 1012 void openscreen(int32_t shape)
4968 {
4969 1012 reset_pal_cycling();
4970 1012 black_opening_count=0;
4971
4972
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1012 if(COOLSCROLL || shape>-1)
4973 {
4974 912 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4975 912 return;
4976 }
4977 else
4978 {
4979 100 Hero.setDontDraw(true);
4980 100 show_subscreen_dmap_dots=false;
4981 100 show_subscreen_numbers=false;
4982 // show_subscreen_items=false;
4983 100 show_subscreen_life=false;
4984 }
4985
4986 100 int32_t x=128;
4987
4988 100 FFCore.warpScriptCheck();
4989
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4990 {
4991 8000 draw_screen(tmpscr);
4992 //? draw_screen already draws the subscreen -DD
4993 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4994 8000 x=128-(((i*128/80)/8)*8);
4995
4996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4997 {
4998 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4999 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5000 8000 }
5001
5002 8000 advanceframe(true);
5003
5004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5005 {
5006 break;
5007 }
5008 8000 }
5009
5010 100 Hero.setDontDraw(false);
5011 100 show_subscreen_items=true;
5012 100 show_subscreen_dmap_dots=true;
5013 1012 }
5014
5015 void closescreen(int32_t shape)
5016 {
5017 reset_pal_cycling();
5018 black_opening_count=0;
5019
5020 if(COOLSCROLL || shape>-1)
5021 {
5022 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5023 return;
5024 }
5025 else
5026 {
5027 Hero.setDontDraw(true);
5028 show_subscreen_dmap_dots=false;
5029 show_subscreen_numbers=false;
5030 // show_subscreen_items=false;
5031 show_subscreen_life=false;
5032 }
5033
5034 int32_t x=128;
5035
5036 FFCore.warpScriptCheck();
5037 for(int32_t i=79; i>=0; --i)
5038 {
5039 draw_screen(tmpscr);
5040 //? draw_screen already draws the subscreen -DD
5041 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5042 x=128-(((i*128/80)/8)*8);
5043
5044 if(x>0)
5045 {
5046 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5047 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5048 }
5049
5050 advanceframe(true);
5051
5052 if(Quit)
5053 {
5054 break;
5055 }
5056 }
5057
5058 Hero.setDontDraw(false);
5059 show_subscreen_items=true;
5060 show_subscreen_dmap_dots=true;
5061 }
5062
5063 179 int32_t TriforceCount()
5064 {
5065 179 int32_t c=0;
5066
5067
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5068
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5069 1044 ++c;
5070
5071 179 return c;
5072 }
5073
5074 int32_t onCustomGame()
5075 {
5076 int32_t file = getsaveslot();
5077
5078 if(file < 0)
5079 return D_O_K;
5080
5081 bool ret = (custom_game(file)!=0);
5082 return ret ? D_CLOSE : D_O_K;
5083 }
5084
5085 int32_t onContinue()
5086 {
5087 return D_CLOSE;
5088 }
5089
5090 int32_t onEsc() // Unused?? -L
5091 {
5092 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5093 }
5094
5095 int32_t onVsync()
5096 {
5097 Throttlefps = !Throttlefps;
5098 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5099 return D_O_K;
5100 }
5101
5102 int32_t onWinPosSave()
5103 {
5104 SaveWinPos = !SaveWinPos;
5105 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5106 return D_O_K;
5107 }
5108 int32_t onIntegerScaling()
5109 {
5110 scaleForceInteger = !scaleForceInteger;
5111 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5112 return D_O_K;
5113 }
5114 int32_t onStretchGame()
5115 {
5116 stretchGame = !stretchGame;
5117 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5118 return D_O_K;
5119 }
5120
5121 int32_t onClickToFreeze()
5122 {
5123 ClickToFreeze = !ClickToFreeze;
5124 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5125 return D_O_K;
5126 }
5127
5128 int32_t OnSaveZCConfig()
5129 {
5130 if(jwin_alert3(
5131 "Save Configuration",
5132 "Are you sure that you wish to save your present configuration settings?",
5133 "This will overwrite your prior settings!",
5134 NULL,
5135 "&Yes",
5136 "&No",
5137 NULL,
5138 'y',
5139 'n',
5140 0,
5141 get_zc_font(font_lfont)) == 1)
5142 {
5143 save_game_configs();
5144 return D_O_K;
5145 }
5146 else return D_O_K;
5147 }
5148
5149 int32_t OnnClearQuestDir()
5150 {
5151 if(jwin_alert3(
5152 "Clear Current Directory Cache",
5153 "Are you sure that you wish to clear the current cached directory?",
5154 "This will default the current directory to the ROOT for this instance of ZC Player!",
5155 NULL,
5156 "&Yes",
5157 "&No",
5158 NULL,
5159 'y',
5160 'n',
5161 0,
5162 get_zc_font(font_lfont)) == 1)
5163 {
5164 zc_set_config("zeldadx","win_qst_dir","");
5165 flush_config_file();
5166 strcpy(qstdir,"");
5167 #ifdef __EMSCRIPTEN__
5168 em_sync_fs();
5169 #endif
5170 return D_O_K;
5171 }
5172 else return D_O_K;
5173 }
5174
5175
5176 int32_t onConsoleZASM()
5177 {
5178 if ( !zasm_debugger )
5179 {
5180 AlertDialog("WARNING: ZASM Debugger",
5181 "Enabling this will open the ZASM Debugger Console"
5182 "\nThis will likely grind ZC to a halt with lag."
5183 "\nTo make any use of this, it is suggested that you read"
5184 "\nthe documentation for 'void Breakpoint(char[] string);'"
5185 " in 'ZScript_Additions.txt'"
5186 "\nThis is not recommended for normal users,"
5187 " and is only intended for ZC developers,"
5188 "\nor quest developers coding directly in ZASM"
5189 "\nAre you sure that you wish to open the ZASM Debugger?",
5190 [&](bool ret,bool)
5191 {
5192 if(ret)
5193 {
5194 FFCore.ZASMPrint(true);
5195 }
5196 }).show();
5197 return D_O_K;
5198 }
5199 else
5200 {
5201 FFCore.ZASMPrint(false);
5202 return D_O_K;
5203 }
5204 }
5205
5206
5207 int32_t onConsoleZScript()
5208 {
5209 if ( !zscript_debugger )
5210 {
5211 AlertDialog("ZScript Debugger",
5212 "Enabling this will open the ZScript Debugger Console"
5213 "\nThis will display any messages logged by scripts,"
5214 " including script errors."
5215 "\nAre you sure that you wish to open the ZScript Debugger?",
5216 [&](bool ret,bool)
5217 {
5218 if(ret)
5219 {
5220 FFCore.ZScriptConsole(true);
5221 }
5222 }).show();
5223 return D_O_K;
5224 }
5225 else
5226 {
5227 FFCore.ZScriptConsole(false);
5228 return D_O_K;
5229 }
5230 }
5231
5232 int32_t onClrConsoleOnReload()
5233 {
5234 clearConsoleOnReload = !clearConsoleOnReload;
5235 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5236 return D_O_K;
5237 }
5238 int32_t onClrConsoleOnLoad()
5239 {
5240 clearConsoleOnLoad = !clearConsoleOnLoad;
5241 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5242 return D_O_K;
5243 }
5244
5245
5246 int32_t onFrameSkip()
5247 {
5248 FrameSkip = !FrameSkip;
5249 return D_O_K;
5250 }
5251
5252 int32_t onSaveDragResize()
5253 {
5254 SaveDragResize = !SaveDragResize;
5255 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5256 return D_O_K;
5257 }
5258
5259 int32_t onDragAspect()
5260 {
5261 DragAspect = !DragAspect;
5262 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5263 return D_O_K;
5264 }
5265
5266 int32_t onTransLayers()
5267 {
5268 TransLayers = !TransLayers;
5269 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5270 return D_O_K;
5271 }
5272
5273 int32_t onNESquit()
5274 {
5275 NESquit = !NESquit;
5276 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5277 return D_O_K;
5278 }
5279
5280 int32_t onVolKeys()
5281 {
5282 volkeys = !volkeys;
5283 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5284 return D_O_K;
5285 }
5286
5287 int32_t onShowFPS()
5288 {
5289 ShowFPS = !ShowFPS;
5290 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5291 return D_O_K;
5292 }
5293
5294 1095803932 bool is_Fkey(int32_t k)
5295 {
5296
2/2
✓ Branch 0 taken 111437688 times.
✓ Branch 1 taken 984366244 times.
1095803932 switch(k)
5297 {
5298 case KEY_F1:
5299 case KEY_F2:
5300 case KEY_F3:
5301 case KEY_F4:
5302 case KEY_F5:
5303 case KEY_F6:
5304 case KEY_F7:
5305 case KEY_F8:
5306 case KEY_F9:
5307 case KEY_F10:
5308 case KEY_F11:
5309 case KEY_F12:
5310 111437688 return true;
5311 }
5312
5313 984366244 return false;
5314 1095803932 }
5315
5316 void kb_getkey(DIALOG *d);
5317
5318 //Used by all keyboard key settings dialogues.
5319 void kb_clearjoystick(DIALOG *d)
5320 {
5321 d->flags|=D_SELECTED;
5322
5323 jwin_button_proc(MSG_DRAW,d,0);
5324 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5325 // text_mode(vc(11));
5326 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5327 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5328
5329 update_hw_screen(true);
5330
5331 clear_keybuf();
5332 int32_t k = next_press_key();
5333 clear_keybuf();
5334
5335 //shnarf
5336 //47=f1
5337 //59=esc
5338 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5339 // *((int32_t*)d->dp3) = k;
5340 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5341
5342
5343 d->flags&=~D_SELECTED;
5344 }
5345
5346 //Clears key to 0.
5347 //Used by all keyboard key settings dialogues.
5348 void kb_clearkey(DIALOG *d);
5349
5350 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5351 {
5352 switch(msg)
5353 {
5354 case MSG_KEY:
5355 case MSG_CLICK:
5356
5357 kb_clearjoystick(d);
5358
5359 while(gui_mouse_b())
5360 {
5361 clear_keybuf();
5362 rest(1);
5363 }
5364
5365 return D_REDRAW;
5366 }
5367
5368 return jwin_button_proc(msg,d,c);
5369 }
5370
5371 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5372 //Only used in keyboard settings dialogues to clear keys.
5373 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5374
5375 void j_getbtn(DIALOG *d)
5376 {
5377 d->flags|=D_SELECTED;
5378 jwin_button_proc(MSG_DRAW,d,0);
5379 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5380 // text_mode(vc(11));
5381 int32_t y = screen->h/2 - 12;
5382 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5383 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5384 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5385
5386 update_hw_screen(true);
5387
5388 int32_t b = next_press_btn();
5389
5390 if(b>=0)
5391 *((int32_t*)d->dp3) = b;
5392
5393 d->flags&=~D_SELECTED;
5394
5395 if (player)
5396 player->joy_on = TRUE;
5397 }
5398
5399 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5400 {
5401 switch(msg)
5402 {
5403 case MSG_KEY:
5404 case MSG_CLICK:
5405
5406 j_getbtn(d);
5407
5408 while(gui_mouse_b()) {
5409 rest(1);
5410 clear_keybuf();
5411 }
5412
5413 return D_REDRAW;
5414 }
5415
5416 return jwin_button_proc(msg,d,c);
5417 }
5418
5419 //shnarf
5420 extern const char *key_str[];
5421 std::string get_keystr(int key);
5422
5423 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5424 //extern int32_t zcmusic_bufsz;
5425
5426 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5427 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5428
5429 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5430 {
5431 //these are here to bypass compiler warnings about unused arguments
5432 c=c;
5433
5434 if(msg==MSG_DRAW)
5435 {
5436 switch(d->w)
5437 {
5438 case 0:
5439 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5440 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5441 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5442 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5443 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5444 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5445 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5446 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5447 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5448 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5449 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5450 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5451 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5452 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5453 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5454 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5455 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5456 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5457 break;
5458
5459 case 1:
5460 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5461 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5462 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5463 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5464 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5465 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5466 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5467 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5468 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5469 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5470 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5471 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5472 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5473 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5474 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5475 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5476 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5477 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5478 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5479 break;
5480
5481 case 2:
5482 sprintf(str_a," %3d",midi_volume);
5483 sprintf(str_b," %3d",digi_volume);
5484 sprintf(str_l," %3d",emusic_volume);
5485 sprintf(str_m," %3dKB",zcmusic_bufsz);
5486 sprintf(str_r," %3d",sfx_volume);
5487 strcpy(str_s,pan_str[pan_style]);
5488 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5489 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5490 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5491 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5492 break;
5493 }
5494 }
5495
5496 return D_O_K;
5497 }
5498
5499 int32_t set_vol(void *dp3, int32_t d2)
5500 {
5501 switch(((int32_t*)dp3)[0])
5502 {
5503 case 0:
5504 midi_volume = zc_min(d2<<3,255);
5505 break;
5506
5507 case 1:
5508 digi_volume = zc_min(d2<<3,255);
5509 break;
5510
5511 case 2:
5512 emusic_volume = zc_min(d2<<3,255);
5513 break;
5514
5515 case 3:
5516 sfx_volume = zc_min(d2<<3,255);
5517 break;
5518 }
5519
5520 // text_mode(vc(11));
5521 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5522 return D_O_K;
5523 }
5524
5525 int32_t set_pan(void *dp3, int32_t d2)
5526 {
5527 pan_style = vbound(d2,0,3);
5528 // text_mode(vc(11));
5529 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5530 return D_O_K;
5531 }
5532
5533 int32_t set_buf(void *dp3, int32_t d2)
5534 {
5535 // text_mode(vc(11));
5536 zcmusic_bufsz = d2 + 1;
5537 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5538 return D_O_K;
5539 }
5540
5541 static int32_t gamepad_btn_list[] =
5542 {
5543 6,
5544 7,8,9,10,11,12,13,14,15,16,17,
5545 18,19,20,21,22,23,24,25,26,27,28,
5546 29,30,31,32,33,34,35,36,37,38,39,
5547 -1
5548 };
5549
5550 static int32_t gamepad_dirs_list[] =
5551 {
5552 40,41,42,43,
5553 44,45,46,47,
5554 48,49,50,51,
5555 52,53,54,55,
5556 56,
5557 -1
5558 };
5559
5560 static TABPANEL gamepad_tabs[] =
5561 {
5562 // (text)
5563 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5564 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5565 { NULL, 0, NULL, 0, NULL }
5566 };
5567
5568 static DIALOG gamepad_dlg[] =
5569 {
5570 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5571 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5572 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5573 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5574 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5575 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5576 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5577 // 6
5578 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5579 // 7
5580 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5581 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5582 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5583 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5584 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5585 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5586 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5587 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5588 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5589 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5590 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5591 // 18
5592 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5593 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5594 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5595 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5596 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5597 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5598 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5599 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5600 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5601 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5602 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5603 // 29
5604 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5605 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5606 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5607 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5608 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5609 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5610 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5611 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5612 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5613 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5614 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5615 // 40
5616 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5617 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5618 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5619 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5620 // 44
5621 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5622 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5623 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5624 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5625 // 48
5626 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5627 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5628 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5629 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5630 // 52
5631 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5632 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5633 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5634 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5635 // 56
5636 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5637 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5638 };
5639
5640 static int32_t keyboard_keys_list[] =
5641 {
5642 6,7,8,9,10,
5643 11,12,13,14,15,16,17,18,19,20,
5644 21,22,23,24,25,26,27,28,29,30,
5645 31,32,33,34,35,36,37,38,39,40,
5646 -1
5647 };
5648
5649 static int32_t keyboard_dirs_list[] =
5650 {
5651 41,42,43,44,
5652 45,46,47,48,
5653 49,50,51,52,
5654 53,54,55,56,
5655 -1
5656 };
5657
5658 static int32_t keyboard_mods_list[] =
5659 {
5660 57,58,59,60,
5661 61,62,63,64,
5662 65,66,67,68,
5663 69,70,71,72,
5664 -1
5665 };
5666
5667 static TABPANEL keyboard_control_tabs[] =
5668 {
5669 // (text)
5670 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5671 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5672 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5673 { NULL, 0, NULL, 0, NULL }
5674 };
5675
5676 static DIALOG keyboard_control_dlg[] =
5677 {
5678 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5679 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5680 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5681 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5682 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5683 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5684 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5685 // Keys
5686 // 6
5687 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5688 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5689 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5690 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5691 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5692 // 11
5693 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5694 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5695 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5696 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5697 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5698 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5699 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5700 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5701 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5702 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5703 // 21
5704 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5705 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5706 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5707 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5708 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5709 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5710 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5711 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5712 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5713 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5714 // 31
5715 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5716 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5717 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5718 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5719 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5720 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5721 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5722 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5723 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5724 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5725 // Dirs
5726 // 41
5727 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5728 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5729 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5730 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5731 // 45
5732 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5733 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5734 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5735 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5736 // 49
5737 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5738 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5739 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5740 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5741 // 53
5742 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5743 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5744 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5745 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5746 // Mods
5747 // 57
5748 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5749 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5750 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5751 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5752 // 61
5753 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5754 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5755 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5756 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5757 // 65
5758 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5759 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5760 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5761 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5762 // 69
5763 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5764 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5765 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5766 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5767 // 73
5768 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5769 };
5770
5771 /*
5772 int32_t midi_dp[3] = {0,147,104};
5773 int32_t digi_dp[3] = {1,147,120};
5774 int32_t pan_dp[3] = {0,147,136};
5775 int32_t buf_dp[3] = {0,147,152};
5776 */
5777 int32_t midi_dp[3] = {0,0,0};
5778 int32_t digi_dp[3] = {1,0,0};
5779 int32_t emus_dp[3] = {2,0,0};
5780 int32_t buf_dp[3] = {0,0,0};
5781 int32_t sfx_dp[3] = {3,0,0};
5782 int32_t pan_dp[3] = {0,0,0};
5783
5784 static DIALOG sound_dlg[] =
5785 {
5786 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5787 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5788 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5789 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5790 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5791 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5792 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5793 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5794 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5795 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5796 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5797 // 10
5798 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5799 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5800 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5801 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5802 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5803 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5804 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5805 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5806 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5807 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5808 //20
5809 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5810 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5811 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5812 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5813 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5814 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5815 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5816 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5817 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5818 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5819 //30
5820 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5821 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5822 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5823 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5824 };
5825
5826 char zc_builddate[80];
5827 char zc_aboutstr[80];
5828
5829 static DIALOG about_dlg[] =
5830 {
5831 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5832 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5833 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5834 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5835 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5836 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5837 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5838 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5839 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5840 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5841 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5842 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5843 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5844 };
5845
5846
5847 static DIALOG quest_dlg[] =
5848 {
5849 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5850 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5851 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5852 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5853 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5854 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5855 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5856 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5857 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5858 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5859 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5860 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5861 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5862 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5863 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5864 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5865 };
5866
5867 static DIALOG triforce_dlg[] =
5868 {
5869 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5870 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5871 // 1
5872 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5873 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5874 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5875 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5876 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5877 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5878 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5879 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5880 // 9
5881 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5882 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5883 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5884 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5885 };
5886
5887 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5888 {
5889 go();
5890 int32_t ret=0;
5891 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5892 comeback();
5893 return ret != 0;
5894 }
5895
5896
5897 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5898 {
5899 if(def!=modulepath)
5900 strcpy(modulepath,def);
5901
5902 if(!usefilename)
5903 {
5904 int32_t i=(int32_t)strlen(modulepath);
5905
5906 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5907 modulepath[i--]=0;
5908 }
5909
5910 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5911 int32_t ret=0;
5912 int32_t sel=0;
5913
5914 if(list==NULL)
5915 {
5916 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5917 }
5918 else
5919 {
5920 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5921 }
5922
5923 return ret!=0;
5924 }
5925
5926 //The Dialogue that loads a ZMOD Module File
5927 int32_t zc_load_zmod_module_file()
5928 {
5929 if ( Playing )
5930 {
5931 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5932 return -1;
5933 }
5934 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5935 return D_CLOSE;
5936
5937 FILE *tempmodule = fopen(modulepath,"r");
5938
5939 if(tempmodule == NULL)
5940 {
5941 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5942 return -1;
5943 }
5944
5945
5946 //Set the module path:
5947 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5948 strcpy(moduledata.module_name, modulepath);
5949 al_trace("New Module Path is: %s \n", moduledata.module_name);
5950 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5951 zcm.init(true); //Load the module values.
5952 moduledata.refresh_title_screen = 1;
5953 // refresh_select_screen = 1;
5954 return D_O_K;
5955 }
5956
5957 static DIALOG module_info_dlg[] =
5958 {
5959 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5960
5961
5962 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5963 //1
5964 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5965 //2
5966 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5967 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5968 //4
5969 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5970 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5971 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5972 //7
5973
5974 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5975 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5976 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5977 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5978 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5979 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5980 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5981 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5982 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5983
5984 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5985 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5986 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5987 };
5988
5989 void about_zcplayer_module(const char *prompt,int32_t initialval)
5990 {
5991
5992 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5993 if ( moduledata.moduletitle[0] != 0 )
5994 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5995
5996 if ( moduledata.moduleauthor[0] != 0 )
5997 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5998
5999 if ( moduledata.moduleinfo0[0] != 0 )
6000 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6001 if ( moduledata.moduleinfo1[0] != 0 )
6002 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6003 if ( moduledata.moduleinfo2[0] != 0 )
6004 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6005 if ( moduledata.moduleinfo3[0] != 0 )
6006 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6007 if ( moduledata.moduleinfo4[0] != 0 )
6008 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6009
6010 char module_date[255];
6011 memset(module_date, 0, sizeof(module_date));
6012 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6013 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6014
6015
6016
6017 char module_vers[255];
6018 memset(module_vers, 0, sizeof(module_vers));
6019 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6020
6021
6022 //sprintf(tilecount,"%d",1);
6023
6024 char module_build[255];
6025 memset(module_build, 0, sizeof(module_build));
6026 if ( moduledata.modbeta )
6027 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6028 else
6029 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6030
6031 module_info_dlg[12].dp = (char*)module_date;
6032 module_info_dlg[13].dp = (char*)module_vers;
6033 module_info_dlg[14].dp = (char*)module_build;
6034
6035 large_dialog(module_info_dlg);
6036
6037 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6038 jwin_center_dialog(module_info_dlg);
6039
6040
6041 }
6042
6043 int32_t onAbout_ZCP_Module()
6044 {
6045 about_zcplayer_module("About Module (.zmod)", 0);
6046 return D_O_K;
6047 }
6048
6049 //New Modules Menu for 2.55+
6050 static MENU zcmodule_menu[] =
6051 {
6052 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6053 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6054
6055 { NULL, NULL, NULL, 0, NULL }
6056 };
6057
6058 int32_t onToggleRecordingNewSaves()
6059 {
6060 if (zc_get_config("zeldadx", "replay_new_saves", false))
6061 {
6062 zc_set_config("zeldadx", "replay_new_saves", false);
6063 }
6064 else
6065 {
6066 zc_set_config("zeldadx", "replay_new_saves", true);
6067 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6068 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6069 }
6070 return D_O_K;
6071 }
6072
6073 int32_t onToggleSnapshotAllFrames()
6074 {
6075 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6076 return D_O_K;
6077 }
6078
6079 int32_t onStopReplayOrRecord()
6080 {
6081 if (replay_is_replaying())
6082 {
6083 replay_quit();
6084 }
6085 else if (replay_get_mode() == ReplayMode::Record)
6086 {
6087 if (!replay_get_meta_bool("test_mode"))
6088 {
6089 jwin_alert("Recording", "You cannot stop recording a save file.",
6090 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6091 return D_CLOSE;
6092 }
6093
6094 if (jwin_alert("Stop Recording",
6095 "Save replay to disk and stop recording?",
6096 "This will stop the recording.",
6097 NULL,
6098 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6099 return D_CLOSE;
6100
6101 replay_save();
6102 replay_stop();
6103 }
6104 return D_O_K;
6105 }
6106
6107 static int32_t handle_on_load_replay(ReplayMode mode)
6108 {
6109 if (Playing)
6110 {
6111 if (jwin_alert("Replay - Warning!",
6112 "Loading a replay will exit the current game.",
6113 "All unsaved progress will be lost.",
6114 "Do you wish to continue?",
6115 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6116 return D_CLOSE;
6117 }
6118
6119 std::string mode_string = replay_mode_to_string(mode);
6120 mode_string[0] = std::toupper(mode_string[0]);
6121
6122 std::string line_1 = "Select a replay file to play back.";
6123 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6124 std::string line_3 = "You can stop the replay and take over manually any time.";
6125 if (mode == ReplayMode::Update)
6126 {
6127 line_1 = "Select a replay file to update.";
6128 line_2 = "WARNING: be sure to back up the zplay file";
6129 line_3 = "and verify that the updated replay works as expected!";
6130 }
6131
6132 if (jwin_alert(mode_string.c_str(),
6133 line_1.c_str(),
6134 line_2.c_str(),
6135 line_3.c_str(),
6136 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6137 {
6138 char replay_path[2048];
6139 strcpy(replay_path, "replays/");
6140 if (jwin_file_select_ex(
6141 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6142 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6143 return D_CLOSE;
6144
6145 replay_quit();
6146 load_replay_file_deferred(mode, replay_path);
6147 Quit = qRESET;
6148 return D_CLOSE;
6149 }
6150 return D_O_K;
6151 }
6152
6153 int32_t onLoadReplay()
6154 {
6155 return handle_on_load_replay(ReplayMode::Replay);
6156 }
6157
6158 int32_t onLoadReplayAssert()
6159 {
6160 return handle_on_load_replay(ReplayMode::Assert);
6161 }
6162
6163 int32_t onLoadReplayUpdate()
6164 {
6165 return handle_on_load_replay(ReplayMode::Update);
6166 }
6167
6168 int32_t onSaveReplay()
6169 {
6170 if (replay_get_mode() == ReplayMode::Record)
6171 {
6172 if (!replay_get_meta_bool("test_mode"))
6173 {
6174 if (jwin_alert("Save Replay",
6175 "This will save a copy of the replay up to this point.",
6176 "The official replay file will be untouched.",
6177 "Do you wish to continue?",
6178 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6179 return D_CLOSE;
6180
6181 char replay_path[2048];
6182 strcpy(replay_path, replay_get_replay_path().string().c_str());
6183 if (jwin_file_select_ex(
6184 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6185 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6186 return D_CLOSE;
6187
6188 if (fileexists(replay_path))
6189 {
6190 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6191 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6192 return D_CLOSE;
6193 }
6194
6195 replay_save(replay_path);
6196 }
6197 else
6198 {
6199 replay_save();
6200 }
6201 }
6202 return D_O_K;
6203 }
6204
6205 static MENU replay_menu[] =
6206 {
6207 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6208 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6209 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6210 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6211 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6212 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6213 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6214
6215 { NULL, NULL, NULL, 0, NULL }
6216 };
6217
6218 static DIALOG credits_dlg[] =
6219 {
6220 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6221 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6222 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6223 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6224 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6225 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6226 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6227 };
6228
6229 116 static ListData dmap_list(dmaplist, &font);
6230
6231 static DIALOG goto_dlg[] =
6232 {
6233 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6234 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6235 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6236 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6237 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6238 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6239 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6240 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6241 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6242 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6243 };
6244
6245 int32_t onGoTo()
6246 {
6247 bool music = false;
6248 music = music;
6249 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6250
6251 goto_dlg[0].dp2=get_zc_font(font_lfont);
6252 goto_dlg[4].d2=cheat_goto_dmap;
6253 goto_dlg[6].dp=cheat_goto_screen_str;
6254
6255 clear_keybuf();
6256
6257 large_dialog(goto_dlg);
6258
6259 if(zc_popup_dialog(goto_dlg,4)==1)
6260 {
6261 // dmap, screen
6262 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6263 };
6264
6265 return D_O_K;
6266 }
6267
6268 int32_t onGoToComplete()
6269 {
6270 if(!Playing)
6271 {
6272 return D_O_K;
6273 }
6274
6275 enter_sys_pal();
6276 music_pause();
6277 pause_all_sfx();
6278 onGoTo();
6279 eat_buttons();
6280
6281 zc_readrawkey(KEY_ESC);
6282
6283 exit_sys_pal();
6284 music_resume();
6285 resume_all_sfx();
6286 return D_O_K;
6287 }
6288
6289 int32_t onCredits()
6290 {
6291 go();
6292
6293 BITMAP *win = create_bitmap_ex(8,222,110);
6294
6295 if(!win)
6296 return D_O_K;
6297
6298 int32_t c=0;
6299 int32_t l=0;
6300 int32_t ol=-1;
6301 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6302 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6303 PALETTE tmppal;
6304
6305 rti_gui.transparency_index = 1;
6306
6307 clear_to_color(win, rti_gui.transparency_index);
6308 draw_rle_sprite(win,rle,0,0);
6309 credits_dlg[0].dp2=get_zc_font(font_lfont);
6310 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6311 credits_dlg[2].dp = win;
6312
6313 zc_set_palette_range(black_palette,0,127,false);
6314
6315 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6316
6317 BITMAP* old_screen = screen;
6318 BITMAP* gui_bmp = zc_get_gui_bmp();
6319 ASSERT(gui_bmp);
6320 clear_to_color(gui_bmp, rti_gui.transparency_index);
6321 screen = gui_bmp;
6322
6323 while(update_dialog(p))
6324 {
6325 throttleFPS();
6326 ++c;
6327 l = zc_max((c>>1)-30,0);
6328
6329 if(l > rle->h)
6330 l = c = 0;
6331
6332 if(l > rle->h - 112)
6333 l = rle->h - 112;
6334
6335 clear_bitmap(win);
6336 draw_rle_sprite(win,rle,0,0-l);
6337
6338 if(c<=64)
6339 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6340
6341 zc_set_palette_range(tmppal,0,127,false);
6342
6343 if(l!=ol)
6344 {
6345 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6346 SCRFIX();
6347 ol=l;
6348 }
6349
6350 update_hw_screen();
6351 }
6352
6353 screen = old_screen;
6354 system_pal(true);
6355 sys_mouse();
6356
6357 shutdown_dialog(p);
6358 destroy_bitmap(win);
6359 //comeback();
6360
6361 rti_gui.transparency_index = 0;
6362 clear_to_color(gui_bmp, rti_gui.transparency_index);
6363
6364 return D_O_K;
6365 }
6366
6367 const char *midilist(int32_t index, int32_t *list_size)
6368 {
6369 if(index<0)
6370 {
6371 *list_size=0;
6372
6373 for(int32_t i=0; i<MAXMIDIS; i++)
6374 if(tunes[i].data)
6375 ++(*list_size);
6376
6377 return NULL;
6378 }
6379
6380 int32_t i=0,m=0;
6381
6382 while(m<=index && i<=MAXMIDIS)
6383 {
6384 if(tunes[i].data)
6385 ++m;
6386
6387 ++i;
6388 }
6389
6390 --i;
6391
6392 if(i==MAXMIDIS && m<index)
6393 return "(null)";
6394
6395 return tunes[i].title;
6396 }
6397
6398 /* ------- MIDI info stuff -------- */
6399
6400 char *text;
6401 midi_info *zmi;
6402 bool dialog_running;
6403 bool listening;
6404
6405 void get_info(int32_t index);
6406
6407 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6408 {
6409 int32_t d2 = d->d2;
6410 int32_t ret = jwin_droplist_proc(msg,d,c);
6411
6412 if(d2!=d->d2)
6413 {
6414 get_info(d->d2);
6415 }
6416
6417 return ret;
6418 }
6419
6420 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6421 {
6422 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6423
6424 int32_t ret = jwin_button_proc(msg,d,c);
6425
6426 if(ret == D_CLOSE)
6427 {
6428 // get current midi index
6429 int32_t index = (d+(d->d1))->d2;
6430 int32_t i=0, m=0;
6431
6432 while(m<=index && i<=MAXMIDIS)
6433 {
6434 if(tunes[i].data)
6435 ++m;
6436
6437 ++i;
6438 }
6439
6440 --i;
6441 jukebox(i);
6442 listening = true;
6443 ret = D_O_K;
6444 }
6445
6446 return ret;
6447 }
6448
6449 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6450 {
6451 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6452
6453 int32_t ret = jwin_button_proc(msg,d,c);
6454
6455 if(ret == D_CLOSE)
6456 {
6457 // get current midi index
6458 int32_t index = (d+(d->d1))->d2;
6459 int32_t i=0, m=0;
6460
6461 while(m<=index && i<=MAXMIDIS)
6462 {
6463 if(tunes[i].data)
6464 ++m;
6465
6466 ++i;
6467 }
6468
6469 --i;
6470
6471 // get file name
6472
6473 int32_t sel=0;
6474 //struct ffblk f;
6475 char title[40] = "Save MIDI: ";
6476 char fname[2048];
6477 memset(fname,0,2048);
6478 static EXT_LIST list[] =
6479 {
6480 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6481 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6482 { NULL, NULL }
6483 };
6484
6485 strcpy(title+11, tunes[i].title);
6486 title[39] = '\0';
6487
6488 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6489 goto done;
6490
6491 if(exists(fname))
6492 {
6493 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6494 goto done;
6495 }
6496
6497 // save midi i
6498
6499 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6500 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6501
6502 done:
6503 chop_path(fname);
6504 ret = D_REDRAW;
6505 }
6506
6507 return ret;
6508 }
6509
6510 116 static ListData midi_list(midilist, &font);
6511
6512 static DIALOG midi_dlg[] =
6513 {
6514 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6515 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6516 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6517 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6518 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6519 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6520 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6521 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6522 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6523 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6524 };
6525
6526 void get_info(int32_t index)
6527 {
6528 int32_t i=0, m=0;
6529
6530 while(m<=index && i<=MAXMIDIS)
6531 {
6532 if(tunes[i].data)
6533 ++m;
6534
6535 ++i;
6536 }
6537
6538 --i;
6539
6540 if(i==MAXMIDIS && m<index)
6541 strcpy(text,"(null)");
6542 else
6543 {
6544 get_midi_info((MIDI*)tunes[i].data,zmi);
6545 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6546 }
6547
6548 midi_dlg[0].dp2=get_zc_font(font_lfont);
6549 midi_dlg[3].dp = text;
6550 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6551 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6552
6553 if(dialog_running)
6554 {
6555 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6556 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6557 }
6558 }
6559
6560 int32_t onMIDICredits()
6561 {
6562 text = (char*)malloc(4096);
6563 zmi = (midi_info*)malloc(sizeof(midi_info));
6564
6565 if(!text || !zmi)
6566 {
6567 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6568 return D_O_K;
6569 }
6570
6571 bool do_pause_midi = midi_pos >= 0 && currmidi;
6572 auto restore_midi = currmidi;
6573 if(do_pause_midi)
6574 {
6575 paused_midi_pos = midi_pos;
6576 stop_midi();
6577 midi_suspended = midissuspHALTED;
6578 }
6579
6580 midi_dlg[0].dp2=get_zc_font(font_lfont);
6581 midi_dlg[2].d1 = 0;
6582 midi_dlg[2].d2 = 0;
6583 midi_dlg[4].flags = D_EXIT;
6584 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6585
6586 listening = false;
6587 dialog_running=false;
6588 get_info(0);
6589
6590 dialog_running=true;
6591
6592 large_dialog(midi_dlg);
6593
6594 zc_popup_dialog(midi_dlg,0);
6595 dialog_running=false;
6596
6597 if(listening)
6598 music_stop();
6599
6600 if(do_pause_midi)
6601 {
6602 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6603 midi_suspended = midissuspRESUME;
6604 currmidi = restore_midi;
6605 midi_pos = paused_midi_pos;
6606 }
6607
6608 if(text) free(text);
6609 if(zmi) free(zmi);
6610 return D_O_K;
6611 }
6612
6613 int32_t onAbout()
6614 {
6615 char buf1[80]={0};
6616 std::ostringstream oss;
6617 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6618 oss << buf1 << '\n';
6619 sprintf(buf1, "%s", ALPHA_VER_STR);
6620 oss << buf1 << '\n';
6621 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6622 oss << buf1 << '\n';
6623 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6624 oss << buf1 << '\n';
6625 sprintf(buf1, "Tag: %s", getReleaseTag());
6626 oss << buf1 << '\n';
6627
6628 InfoDialog("About ZC", oss.str()).show();
6629 return D_O_K;
6630 }
6631
6632 int32_t onQuest()
6633 {
6634 char fname[100];
6635 strcpy(fname, get_filename(qstpath));
6636 quest_dlg[0].dp2=get_zc_font(font_lfont);
6637 quest_dlg[1].dp = fname;
6638
6639 if(QHeader.quest_number==0)
6640 sprintf(str_a,"Custom");
6641 else
6642 sprintf(str_a,"%d",QHeader.quest_number);
6643
6644 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6645
6646 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6647 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6648
6649 large_dialog(quest_dlg);
6650
6651 zc_popup_dialog(quest_dlg, 0);
6652 return D_O_K;
6653 }
6654
6655 void call_vidmode_dlg();
6656 int32_t onVidMode()
6657 {
6658 call_vidmode_dlg();
6659 return D_O_K;
6660 }
6661
6662 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6663 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6664 //Added an extra statement, so that if the key is cleared to 0, the cleared
6665 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6666
6667 void load_ukeys(int32_t* arr)
6668 {
6669 arr[ukey_a] = Akey;
6670 arr[ukey_b] = Bkey;
6671 arr[ukey_s] = Skey;
6672 arr[ukey_l] = Lkey;
6673 arr[ukey_r] = Rkey;
6674 arr[ukey_p] = Pkey;
6675 arr[ukey_ex1] = Exkey1;
6676 arr[ukey_ex2] = Exkey2;
6677 arr[ukey_ex3] = Exkey3;
6678 arr[ukey_ex4] = Exkey4;
6679 arr[ukey_du] = DUkey;
6680 arr[ukey_dd] = DDkey;
6681 arr[ukey_dl] = DLkey;
6682 arr[ukey_dr] = DRkey;
6683 arr[ukey_mod1a] = cheat_modifier_keys[0];
6684 arr[ukey_mod1b] = cheat_modifier_keys[1];
6685 arr[ukey_mod2a] = cheat_modifier_keys[2];
6686 arr[ukey_mod2b] = cheat_modifier_keys[3];
6687 };
6688
6689 static const char* ukey_names[] = {
6690 "A", "B", "Start", "L", "R", "Map",
6691 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6692 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6693 "Cheat Mod R1", "Cheat Mod R2",
6694 };
6695 std::string get_ukey_name(int32_t k)
6696 {
6697 if (k < num_ukey) return ukey_names[k];
6698 return "";
6699 }
6700
6701 int32_t onKeyboard()
6702 {
6703 int32_t a = Akey;
6704 int32_t b = Bkey;
6705 int32_t s = Skey;
6706 int32_t l = Lkey;
6707 int32_t r = Rkey;
6708 int32_t p = Pkey;
6709 int32_t ex1 = Exkey1;
6710 int32_t ex2 = Exkey2;
6711 int32_t ex3 = Exkey3;
6712 int32_t ex4 = Exkey4;
6713 int32_t du = DUkey;
6714 int32_t dd = DDkey;
6715 int32_t dl = DLkey;
6716 int32_t dr = DRkey;
6717 int32_t mod1a = cheat_modifier_keys[0];
6718 int32_t mod1b = cheat_modifier_keys[1];
6719 int32_t mod2a = cheat_modifier_keys[2];
6720 int32_t mod2b = cheat_modifier_keys[3];
6721 bool done=false;
6722 int32_t ret;
6723
6724 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6725
6726 large_dialog(keyboard_control_dlg);
6727
6728 while(!done)
6729 {
6730 ret = zc_popup_dialog(keyboard_control_dlg,3);
6731
6732 if(ret==3) // OK
6733 {
6734 int32_t ukeys[num_ukey];
6735 load_ukeys(ukeys);
6736 std::vector<std::string> uniqueError;
6737 for(int32_t q = 0; q < num_ukey; ++q)
6738 {
6739 for(int32_t p = q+1; p < num_ukey; ++p)
6740 {
6741 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6742 {
6743 char buf[64];
6744 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6745 std::string str(buf);
6746 uniqueError.push_back(str);
6747 }
6748 }
6749 }
6750 if(uniqueError.size() == 0)
6751 {
6752 done = true;
6753 save_control_configs(true);
6754 }
6755 else
6756 {
6757 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6758 box_out("Cannot have duplicate keybinds!"); box_eol();
6759 for(std::vector<std::string>::iterator it = uniqueError.begin();
6760 it != uniqueError.end(); ++it)
6761 {
6762 box_out((*it).c_str()); box_eol();
6763 }
6764 box_end(true);
6765 }
6766 }
6767 else // Cancel
6768 {
6769 Akey = a;
6770 Bkey = b;
6771 Skey = s;
6772 Lkey = l;
6773 Rkey = r;
6774 Pkey = p;
6775 Exkey1 = ex1;
6776 Exkey2 = ex2;
6777 Exkey3 = ex3;
6778 Exkey4 = ex4;
6779 DUkey = du;
6780 DDkey = dd;
6781 DLkey = dl;
6782 DRkey = dr;
6783 cheat_modifier_keys[0] = mod1a;
6784 cheat_modifier_keys[1] = mod1b;
6785 cheat_modifier_keys[2] = mod2a;
6786 cheat_modifier_keys[3] = mod2b;
6787
6788 done=true;
6789 }
6790
6791 rest(1);
6792 }
6793
6794 return D_O_K;
6795 }
6796
6797 int32_t onGamepad()
6798 {
6799 int32_t a = Abtn;
6800 int32_t b = Bbtn;
6801 int32_t s = Sbtn;
6802 int32_t l = Lbtn;
6803 int32_t r = Rbtn;
6804 int32_t m = Mbtn;
6805 int32_t p = Pbtn;
6806 int32_t ex1 = Exbtn1;
6807 int32_t ex2 = Exbtn2;
6808 int32_t ex3 = Exbtn3;
6809 int32_t ex4 = Exbtn4;
6810 int32_t up = DUbtn;
6811 int32_t down = DDbtn;
6812 int32_t left = DLbtn;
6813 int32_t right = DRbtn;
6814
6815 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6816 if(analog_movement)
6817 gamepad_dlg[56].flags|=D_SELECTED;
6818 else
6819 gamepad_dlg[56].flags&=~D_SELECTED;
6820
6821 large_dialog(gamepad_dlg);
6822
6823 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6824
6825 if(ret == 4) //OK
6826 {
6827 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6828 save_control_configs(false);
6829 }
6830 else //Cancel
6831 {
6832 Abtn = a;
6833 Bbtn = b;
6834 Sbtn = s;
6835 Lbtn = l;
6836 Rbtn = r;
6837 Mbtn = m;
6838 Pbtn = p;
6839 Exbtn1 = ex1;
6840 Exbtn2 = ex2;
6841 Exbtn3 = ex3;
6842 Exbtn4 = ex4;
6843 DUbtn = up;
6844 DDbtn = down;
6845 DLbtn = left;
6846 DRbtn = right;
6847 }
6848
6849 return D_O_K;
6850 }
6851
6852 int32_t onCheatKeys()
6853 {
6854 int32_t oldcheats[Cheat::Last][2];
6855 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6856
6857 bool done=false;
6858
6859 while(!done)
6860 {
6861 bool confirm = false;
6862 CheatKeysDialog(&confirm).show();
6863 if(confirm) // OK
6864 {
6865 std::vector<std::string> uniqueError;
6866 char buf[512];
6867 for(size_t q = 1; q < Cheat::Last; ++q)
6868 {
6869 if(cheatkeys[q][1] && !cheatkeys[q][0])
6870 {
6871 cheatkeys[q][0] = cheatkeys[q][1];
6872 cheatkeys[q][1] = 0;
6873 }
6874 }
6875 for(size_t q = 1; q < Cheat::Last; ++q)
6876 {
6877 if(!bindable_cheat((Cheat)q)) continue;
6878 for(size_t p = q+1; p < Cheat::Last; ++p)
6879 {
6880 if(!bindable_cheat((Cheat)p)) continue;
6881 for(size_t q2 = 0; q2 <= 1; ++q2)
6882 for(size_t p2 = 0; p2 <= 1; ++p2)
6883 {
6884 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6885 {
6886 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6887 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6888 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6889 get_keystr(cheatkeys[q][q2])));
6890 }
6891 }
6892 }
6893 }
6894 if(uniqueError.size() == 0)
6895 {
6896 done = true;
6897 save_cheatkeys();
6898 }
6899 else
6900 {
6901 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6902 box_out("Cannot have duplicate keybinds!"); box_eol();
6903 for(std::vector<std::string>::iterator it = uniqueError.begin();
6904 it != uniqueError.end(); ++it)
6905 {
6906 box_out((*it).c_str()); box_eol();
6907 }
6908 box_end(true);
6909 }
6910 }
6911 else // Cancel
6912 {
6913 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6914 done=true;
6915 }
6916 rest(1);
6917 }
6918
6919 return D_O_K;
6920 }
6921
6922 int32_t onSound()
6923 {
6924 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6925 {
6926 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6927 {
6928 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6929 }
6930 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6931 {
6932 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6933 }
6934 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6935 {
6936 emusic_volume = (int32_t)FFCore.usr_music_volume;
6937 }
6938 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6939 {
6940 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6941 }
6942 }
6943 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6944 {
6945 pan_style = (int32_t)FFCore.usr_panstyle;
6946 }
6947
6948 int32_t m = midi_volume;
6949 int32_t d = digi_volume;
6950 int32_t e = emusic_volume;
6951 int32_t b = zcmusic_bufsz;
6952 int32_t s = sfx_volume;
6953 int32_t p = pan_style;
6954 pan_style = vbound(pan_style,0,3);
6955
6956 sound_dlg[0].dp2=get_zc_font(font_lfont);
6957
6958 large_dialog(sound_dlg);
6959
6960 midi_dp[1] = sound_dlg[6].x;
6961 midi_dp[2] = sound_dlg[6].y;
6962 digi_dp[1] = sound_dlg[7].x;
6963 digi_dp[2] = sound_dlg[7].y;
6964 emus_dp[1] = sound_dlg[8].x;
6965 emus_dp[2] = sound_dlg[8].y;
6966 buf_dp[1] = sound_dlg[9].x;
6967 buf_dp[2] = sound_dlg[9].y;
6968 sfx_dp[1] = sound_dlg[10].x;
6969 sfx_dp[2] = sound_dlg[10].y;
6970 pan_dp[1] = sound_dlg[11].x;
6971 pan_dp[2] = sound_dlg[11].y;
6972 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6973 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6974 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6975 sound_dlg[18].d2 = zcmusic_bufsz;
6976 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6977 sound_dlg[20].d2 = pan_style;
6978
6979 int32_t ret = zc_popup_dialog(sound_dlg,1);
6980
6981 if(ret==2)
6982 {
6983 master_volume(digi_volume,midi_volume);
6984 if (zcmusic)
6985 zcmusic_set_volume(zcmusic, emusic_volume);
6986
6987 int32_t temp_volume = sfx_volume;
6988 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
6989 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6990 for(int32_t i=0; i<WAV_COUNT; ++i)
6991 {
6992 //allegro assertion fails when passing in -1 as voice -DD
6993 if(sfx_voice[i] > 0)
6994 voice_set_volume(sfx_voice[i], temp_volume);
6995 }
6996 zc_set_config(sfx_sect,"digi",digi_volume);
6997 zc_set_config(sfx_sect,"midi",midi_volume);
6998 zc_set_config(sfx_sect,"sfx",sfx_volume);
6999 zc_set_config(sfx_sect,"emusic",emusic_volume);
7000 zc_set_config(sfx_sect,"pan",pan_style);
7001 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7002 }
7003 else
7004 {
7005 midi_volume = m;
7006 digi_volume = d;
7007 emusic_volume = e;
7008 zcmusic_bufsz = b;
7009 sfx_volume = s;
7010 pan_style = p;
7011 }
7012
7013 return D_O_K;
7014 }
7015
7016 int32_t queding(char const* s1, char const* s2, char const* s3)
7017 {
7018 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7019 }
7020
7021 int32_t onQuit()
7022 {
7023 if(Playing)
7024 {
7025 int32_t ret=0;
7026
7027 if(get_qr(qr_NOCONTINUE))
7028 {
7029 if(standalone_mode)
7030 {
7031 ret=queding("End current game?",
7032 "The continue screen is disabled; the game",
7033 "will be reloaded from the last save.");
7034 }
7035 else
7036 {
7037 ret=queding("End current game?",
7038 "The continue screen is disabled. You will",
7039 "be returned to the file select screen.");
7040 }
7041 }
7042 else
7043 ret=queding("End current game?",NULL,NULL);
7044
7045 if(ret==1)
7046 {
7047 disableClickToFreeze=false;
7048 Quit=qQUIT;
7049
7050 // Trying to evade a door repair charge?
7051 if(repaircharge)
7052 {
7053 game->change_drupy(-repaircharge);
7054 repaircharge=0;
7055 }
7056
7057 return D_CLOSE;
7058 }
7059 }
7060
7061 return D_O_K;
7062 }
7063
7064 int32_t onTryQuitMenu()
7065 {
7066 return onTryQuit(true);
7067 }
7068
7069 int32_t onTryQuit(bool inMenu)
7070 {
7071 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7072 {
7073 if(active_cutscene.can_f6())
7074 {
7075 if(get_qr(qr_OLD_F6))
7076 {
7077 if(inMenu) onQuit();
7078 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7079 }
7080 else
7081 {
7082 disableClickToFreeze=false;
7083 GameFlags |= GAMEFLAG_TRYQUIT;
7084 }
7085 return D_CLOSE;
7086 }
7087 else active_cutscene.error();
7088 }
7089
7090 return D_O_K;
7091 }
7092
7093 int32_t onReset()
7094 {
7095 if(queding(" Reset system? ",NULL,NULL)==1)
7096 {
7097 disableClickToFreeze=false;
7098 Quit=qRESET;
7099 replay_quit();
7100 return D_CLOSE;
7101 }
7102
7103 return D_O_K;
7104 }
7105
7106 int32_t onExit()
7107 {
7108 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7109 {
7110 Quit=qEXIT;
7111 return D_CLOSE;
7112 }
7113
7114 return D_O_K;
7115 }
7116
7117 int32_t onTitle_NES()
7118 {
7119 title_version=0;
7120 zc_set_config(cfg_sect,"title",title_version);
7121 return D_O_K;
7122 }
7123 int32_t onTitle_DX()
7124 {
7125 title_version=1;
7126 zc_set_config(cfg_sect,"title",title_version);
7127 return D_O_K;
7128 }
7129 int32_t onTitle_25()
7130 {
7131 title_version=2;
7132 zc_set_config(cfg_sect,"title",title_version);
7133 return D_O_K;
7134 }
7135
7136 int32_t onDebug()
7137 {
7138 if(debug_enabled)
7139 set_debug(!get_debug());
7140 return D_O_K;
7141 }
7142
7143 int32_t onHeartBeep()
7144 {
7145 heart_beep=!heart_beep;
7146 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7147 return D_O_K;
7148 }
7149
7150 int32_t onSaveIndicator()
7151 {
7152 use_save_indicator = use_save_indicator ? 0 : 1;
7153 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7154 return D_O_K;
7155 }
7156
7157 int32_t onEpilepsy()
7158 {
7159 if(jwin_alert3(
7160 "Epilepsy Flash Reduction",
7161 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7162 "Disabling this will restore standard flash and wavy behaviour.",
7163 "Proceed?",
7164 "&Yes",
7165 "&No",
7166 NULL,
7167 'y',
7168 'n',
7169 0,
7170 get_zc_font(font_lfont)) == 1)
7171 {
7172 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7173 zc_set_config("zeldadx","checked_epilepsy",1);
7174 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7175 }
7176 return D_O_K;
7177 }
7178
7179 int32_t onTriforce()
7180 {
7181 for(int32_t i=0; i<MAXINITTABS; ++i)
7182 {
7183 init_tabs[i].flags&=~D_SELECTED;
7184 }
7185
7186 init_tabs[3].flags=D_SELECTED;
7187 return onCheatConsole();
7188 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7189 for(int32_t i=1; i<=8; i++)
7190 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7191
7192 if(zc_popup_dialog (triforce_dlg,-1)==9)
7193 {
7194 for(int32_t i=1; i<=8; i++)
7195 {
7196 game->lvlitems[i] &= ~liTRIFORCE;
7197 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7198 }
7199 }
7200 return D_O_K;*/
7201 }
7202
7203 bool rc = false;
7204 /*
7205 int32_t onEquipment()
7206 {
7207 for (int32_t i=0; i<MAXINITTABS; ++i)
7208 {
7209 init_tabs[i].flags&=~D_SELECTED;
7210 }
7211 init_tabs[0].flags=D_SELECTED;
7212 return onCheatConsole();
7213 }
7214 */
7215
7216 int32_t onItems()
7217 {
7218 for(int32_t i=0; i<MAXINITTABS; ++i)
7219 {
7220 init_tabs[i].flags&=~D_SELECTED;
7221 }
7222
7223 init_tabs[1].flags=D_SELECTED;
7224 return onCheatConsole();
7225 }
7226
7227 static DIALOG getnum_dlg[] =
7228 {
7229 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7230 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7231 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7232 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7233 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7234 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7235 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7236 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7237 };
7238
7239 int32_t getnumber(const char *prompt,int32_t initialval)
7240 {
7241 char buf[20];
7242 sprintf(buf,"%d",initialval);
7243 getnum_dlg[0].dp=(void *)prompt;
7244 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7245 getnum_dlg[2].dp=buf;
7246
7247 large_dialog(getnum_dlg);
7248
7249 if(zc_popup_dialog(getnum_dlg,2)==3)
7250 return atoi(buf);
7251
7252 return initialval;
7253 }
7254
7255 int32_t onLife()
7256 {
7257 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7258 cheats_enqueue(Cheat::Life, value);
7259 return D_O_K;
7260 }
7261
7262 int32_t onHeartC()
7263 {
7264 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7265 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7266 cheats_enqueue(Cheat::MaxLife, max_life);
7267 cheats_enqueue(Cheat::Life, life);
7268 return D_O_K;
7269 }
7270
7271 int32_t onMagicC()
7272 {
7273 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7274 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7275 cheats_enqueue(Cheat::MaxMagic, max_magic);
7276 cheats_enqueue(Cheat::Magic, magic);
7277 return D_O_K;
7278 }
7279
7280 int32_t onRupies()
7281 {
7282 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7283 cheats_enqueue(Cheat::Rupies, value);
7284 return D_O_K;
7285 }
7286
7287 int32_t onMaxBombs()
7288 {
7289 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7290 cheats_enqueue(Cheat::MaxBombs, value);
7291 cheats_enqueue(Cheat::Bombs, value);
7292 return D_O_K;
7293 }
7294
7295 int32_t onRefillLife()
7296 {
7297 cheats_enqueue(Cheat::Life, game->get_maxlife());
7298 return D_O_K;
7299 }
7300 int32_t onRefillMagic()
7301 {
7302 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7303 return D_O_K;
7304 }
7305 int32_t onClock()
7306 {
7307 cheats_enqueue(Cheat::Clock);
7308 return D_O_K;
7309 }
7310
7311 int32_t onQstPath()
7312 {
7313 char path[2048];
7314
7315 chop_path(qstdir);
7316 strcpy(path,qstdir);
7317
7318 go();
7319
7320 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7321 {
7322 chop_path(path);
7323 fix_filename_case(path);
7324 fix_filename_slashes(path);
7325 strcpy(qstdir,path);
7326 strcpy(qstpath,qstdir);
7327 }
7328
7329 comeback();
7330 return D_O_K;
7331 }
7332
7333 #include "dialog/cheat_dialog.h"
7334 int32_t onCheat()
7335 {
7336 call_setcheat_dialog();
7337 game->set_cheat(maxcheat);
7338 if(cheat) game->did_cheat(true);
7339 return D_O_K;
7340 }
7341
7342 int32_t onCheatRupies()
7343 {
7344 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7345 return D_O_K;
7346 }
7347
7348 int32_t onCheatArrows()
7349 {
7350 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7351 return D_O_K;
7352 }
7353
7354 int32_t onCheatBombs()
7355 {
7356 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7357 return D_O_K;
7358 }
7359
7360 // *** screen saver
7361
7362 9286474 int32_t after_time()
7363 {
7364
1/2
✓ Branch 0 taken 9286474 times.
✗ Branch 1 not taken.
9286474 if(ss_enable == 0)
7365 return INT_MAX;
7366
7367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
9286474 if(ss_after <= 0)
7368 return 5 * 60;
7369
7370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
9286474 if(ss_after <= 3)
7371 return ss_after * 15 * 60;
7372
7373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286474 times.
9286474 if(ss_after <= 13)
7374 return (ss_after - 3) * 60 * 60;
7375
7376 9286474 return MAX_IDLE + 1;
7377 9286474 }
7378
7379 static const char *after_str[15] =
7380 {
7381 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7382 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7383 "Never"
7384 };
7385
7386 const char *after_list(int32_t index, int32_t *list_size)
7387 {
7388 if(index < 0)
7389 {
7390 *list_size = 15;
7391 return NULL;
7392 }
7393
7394 return after_str[index];
7395 }
7396
7397 116 static ListData after__list(after_list, &font);
7398
7399 static DIALOG scrsaver_dlg[] =
7400 {
7401 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7402 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7403 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7404 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7405 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7406 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7407 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7408 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7409 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7410 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7411 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7412 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7413 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7414 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7415 };
7416
7417 int32_t onScreenSaver()
7418 {
7419 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7420 int32_t oldcfgs[3];
7421 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7422 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7423 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7424
7425 large_dialog(scrsaver_dlg);
7426
7427 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7428
7429 if(ret == 8 || ret == 9)
7430 {
7431 ss_after = scrsaver_dlg[5].d1;
7432 ss_speed = scrsaver_dlg[6].d2;
7433 ss_density = scrsaver_dlg[7].d2;
7434 if(oldcfgs[0] != ss_after)
7435 zc_set_config(cfg_sect,"ss_after",ss_after);
7436 if(oldcfgs[1] != ss_speed)
7437 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7438 if(oldcfgs[2] != ss_density)
7439 zc_set_config(cfg_sect,"ss_density",ss_density);
7440 }
7441
7442 if(ret == 9)
7443 // preview Screen Saver
7444 {
7445 clear_keybuf();
7446 Matrix(ss_speed, ss_density, 30);
7447 system_pal(true);
7448 sys_mouse();
7449 }
7450
7451 return D_O_K;
7452 }
7453
7454 /***** Menus *****/
7455
7456 static MENU game_menu[] =
7457 {
7458 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7459 { (char *)"", NULL, NULL, 0, NULL },
7460 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7461 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7462 { (char *)"", NULL, NULL, 0, NULL },
7463 #ifdef __EMSCRIPTEN__
7464 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7465 #elif defined(ALLEGRO_MACOSX)
7466 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7467 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7468 #else
7469 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7470 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7471 #endif
7472 { NULL, NULL, NULL, 0, NULL }
7473 };
7474
7475 static MENU title_menu[] =
7476 {
7477 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7478 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7479 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7480 { NULL, NULL, NULL, 0, NULL }
7481 };
7482
7483 static MENU snapshot_format_menu[] =
7484 {
7485 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7486 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7487 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7488 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7489 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7490 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7491 { NULL, NULL, NULL, 0, NULL }
7492 };
7493
7494 static MENU controls_menu[] =
7495 {
7496 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7497 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7498 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7499 { NULL, NULL, NULL, 0, NULL }
7500 };
7501
7502 static MENU name_entry_mode_menu[] =
7503 {
7504 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7505 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7506 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7507 { NULL, NULL, NULL, 0, NULL }
7508 };
7509
7510 static void set_controls_menu_active()
7511 {
7512
7513 }
7514
7515 static MENU window_menu[] =
7516 {
7517 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7518 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7519 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7520 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7521 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7522 { NULL, NULL, NULL, 0, NULL }
7523 };
7524 static MENU options_menu[] =
7525 {
7526 { "&Title Screen", NULL, title_menu, 0, NULL },
7527 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7528 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7529 { "&Window Settings", NULL, window_menu, 0, NULL },
7530 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7531 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7532 { NULL, NULL, NULL, 0, NULL }
7533 };
7534 static MENU settings_menu[] =
7535 {
7536 { "&Sound...", onSound, NULL, 0, NULL },
7537 { "C&ontrols", NULL, controls_menu, 0, NULL },
7538 { "", NULL, NULL, 0, NULL },
7539 { "Options", NULL, options_menu, 0, NULL },
7540 { "", NULL, NULL, 0, NULL },
7541 //
7542 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7543 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7544 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7545 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7546 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7547 //
7548 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7549 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7550 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7551 { "", NULL, NULL, 0, NULL },
7552 { "Debu&g", onDebug, NULL, 0, NULL },
7553 //
7554 { NULL, NULL, NULL, 0, NULL }
7555 };
7556
7557
7558 static MENU misc_menu[] =
7559 {
7560 { (char *)"&About...", onAbout, NULL, 0, NULL },
7561 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7562 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7563 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7564 { (char *)"", NULL, NULL, 0, NULL },
7565 //5
7566 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7567 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7568 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7569 { (char *)"", NULL, NULL, 0, NULL },
7570 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7571 //10
7572 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7573 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7574 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7575 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7576 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7577 //15
7578 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7579 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7580 { NULL, NULL, NULL, 0, NULL }
7581 };
7582
7583 static MENU refill_menu[] =
7584 {
7585 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7586 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7587 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7588 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7589 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7590 { NULL, NULL, NULL, 0, NULL }
7591 };
7592
7593 static MENU show_menu[] =
7594 {
7595 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7596 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7597 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7598 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7599 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7600 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7601 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7602 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7603 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7604 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7605 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7606 { (char *)"", NULL, NULL, 0, NULL },
7607 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7608 { (char *)"", NULL, NULL, 0, NULL },
7609 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7610 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7611 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7612 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7613 { NULL, NULL, NULL, 0, NULL }
7614 };
7615
7616 static MENU cheat_menu[] =
7617 {
7618 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7619 { (char *)"", NULL, NULL, 0, NULL },
7620 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7621 { (char *)"", NULL, NULL, 0, NULL },
7622 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7623 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7624 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7625 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7626 { (char *)"", NULL, NULL, 0, NULL },
7627 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7628 { (char *)"", NULL, NULL, 0, NULL },
7629 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7630 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7631 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7632 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7633 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7634 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7635 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7636 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7637 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7638 { NULL, NULL, NULL, 0, NULL }
7639 };
7640
7641 #if DEVLEVEL > 0
7642 int32_t devLogging();
7643 int32_t devDebug();
7644 int32_t devTimestmp();
7645 #if DEVLEVEL > 1
7646 int32_t setCheat();
7647 #endif //DEVLEVEL > 1
7648 enum
7649 {
7650 dv_log,
7651 // dv_dbg,
7652 dv_tmpstmp,
7653 #if DEVLEVEL > 1
7654 dv_nil,
7655 dv_setcheat,
7656 #endif //DEVLEVEL > 1
7657 dv_max
7658 };
7659 static MENU dev_menu[] =
7660 {
7661 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7662 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7663 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7664 #if DEVLEVEL > 1
7665 { (char *)"", NULL, NULL, 0, NULL },
7666 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7667 #endif //DEVLEVEL > 1
7668 { NULL, NULL, NULL, 0, NULL }
7669 };
7670 int32_t devLogging()
7671 {
7672 dev_logging = !dev_logging;
7673 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7674 return D_O_K;
7675 }
7676 // int32_t devDebug()
7677 // {
7678 // dev_debug = !dev_debug;
7679 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7680 // return D_O_K;
7681 // }
7682 int32_t devTimestmp()
7683 {
7684 dev_timestmp = !dev_timestmp;
7685 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7686 return D_O_K;
7687 }
7688 #if DEVLEVEL > 1
7689 int32_t setCheat()
7690 {
7691 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7692 return D_O_K;
7693 }
7694 #endif //DEVLEVEL > 1
7695 #endif //DEVLEVEL > 0
7696
7697 MENU the_player_menu[] =
7698 {
7699 { (char *)"&Game", NULL, game_menu, 0, NULL },
7700 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7701 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7702 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7703 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7704 #if DEVLEVEL > 0
7705 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7706 #endif
7707 { NULL, NULL, NULL, 0, NULL }
7708 };
7709 int32_t onPauseInBackground()
7710 {
7711 if(jwin_alert3(
7712 "Toggle Pause In Background",
7713 "This action will change whether ZC Player pauses when the window loses focus.",
7714 "",
7715 "Proceed?",
7716 "&Yes",
7717 "&No",
7718 NULL,
7719 'y',
7720 'n',
7721 0,
7722 get_zc_font(font_lfont)) == 1)
7723 {
7724 pause_in_background = pause_in_background ? 0 : 1;
7725 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7726 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7727 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7728 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7729 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7730 }
7731 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7732 return D_O_K;
7733 }
7734
7735 int32_t onKeyboardEntry()
7736 {
7737 NameEntryMode=0;
7738 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7739 return D_O_K;
7740 }
7741
7742 int32_t onLetterGridEntry()
7743 {
7744 NameEntryMode=1;
7745 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7746 return D_O_K;
7747 }
7748
7749 int32_t onExtLetterGridEntry()
7750 {
7751 NameEntryMode=2;
7752 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7753 return D_O_K;
7754 }
7755
7756 static BITMAP* oldscreen;
7757 int32_t onFullscreenMenu()
7758 {
7759 // super hacks
7760 screen = oldscreen;
7761 if (onFullscreen() == D_REDRAW)
7762 {
7763 oldscreen = screen;
7764 }
7765 screen = menu_bmp;
7766 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7767 return D_O_K;
7768 }
7769
7770 116 void fix_menu()
7771 {
7772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7773 116 settings_menu[13].text = NULL;
7774 116 }
7775
7776 static DIALOG system_dlg[] =
7777 {
7778 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7779 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7780 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7781 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7782 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7783 #ifndef ALLEGRO_MACOSX
7784 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7785 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7786 #else
7787 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7788 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7789 #endif
7790 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7791 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7792 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7793 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7794 };
7795
7796 void reset_snapshot_format_menu()
7797 {
7798 for(int32_t i=0; i<ssfmtMAX; ++i)
7799 {
7800 snapshot_format_menu[i].flags=0;
7801 }
7802 }
7803
7804 int32_t onSetSnapshotFormat()
7805 {
7806 switch(active_menu->text[1])
7807 {
7808 case 'B': //"&BMP"
7809 SnapshotFormat=0;
7810 break;
7811
7812 case 'G': //"&GIF"
7813 SnapshotFormat=1;
7814 break;
7815
7816 case 'J': //"&JPG"
7817 SnapshotFormat=2;
7818 break;
7819
7820 case 'P': //"&PNG"
7821 SnapshotFormat=3;
7822 break;
7823
7824 case 'C': //"PC&X"
7825 SnapshotFormat=4;
7826 break;
7827
7828 case 'T': //"&TGA"
7829 SnapshotFormat=5;
7830 break;
7831
7832 case 'L': //"&LBM"
7833 SnapshotFormat=6;
7834 break;
7835 }
7836 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7837
7838 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7839 return D_O_K;
7840 }
7841
7842
7843 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7844 {
7845 PALETTE tmp;
7846
7847 for(int32_t i=0; i<256; i++)
7848 {
7849 tmp[i].r=r;
7850 tmp[i].g=g;
7851 tmp[i].b=b;
7852 }
7853
7854 fade_interpolate(src,tmp,dest,pos,from,to);
7855 }
7856
7857 14 void system_pal(bool force)
7858 {
7859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7860 14 is_sys_pal = true;
7861 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7862 14 hw_palette = &syspal;
7863 14 update_hw_pal = true;
7864 14 }
7865
7866 static uint32_t entered_sys_pal = 0;
7867 14 void enter_sys_pal()
7868 {
7869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7870 {
7871 if(entered_sys_pal)
7872 ++entered_sys_pal;
7873 return;
7874 }
7875 14 sys_mouse();
7876 14 system_pal(true);
7877 14 ++entered_sys_pal;
7878 14 }
7879 14 void exit_sys_pal()
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7882 {
7883
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7884 {
7885 14 game_pal();
7886 14 game_mouse();
7887 14 }
7888 14 }
7889 14 }
7890
7891 void switch_out_callback()
7892 {
7893 if (pause_in_background && !MenuOpen)
7894 {
7895 System();
7896 }
7897 }
7898
7899 void switch_in_callback()
7900 {
7901 }
7902
7903 423 void game_pal()
7904 {
7905 423 is_sys_pal = false;
7906 423 entered_sys_pal = 0;
7907 423 hw_palette = &RAMpal;
7908 423 update_hw_pal = true;
7909 423 }
7910
7911 static char bar_str[] = "";
7912
7913 14 void music_pause()
7914 {
7915 //al_pause_duh(tmplayer);
7916 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7918 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7919 14 zc_midi_pause();
7920 14 }
7921
7922 void music_resume()
7923 {
7924 //al_resume_duh(tmplayer);
7925 zcmusic_pause(zcmusic, ZCM_RESUME);
7926 if (zcmixer->oldtrack)
7927 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7928 zc_midi_resume();
7929 }
7930
7931 3360 void music_stop()
7932 {
7933 //al_stop_duh(tmplayer);
7934 //unload_duh(tmusic);
7935 //tmusic=NULL;
7936 //tmplayer=NULL;
7937 3360 zcmusic_stop(zcmusic);
7938 3360 zcmusic_unload_file(zcmusic);
7939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if (zcmixer->oldtrack)
7940 {
7941 zcmusic_stop(zcmixer->oldtrack);
7942 zcmusic_unload_file(zcmixer->oldtrack);
7943 }
7944 //if (zcmixer->newtrack)
7945 //{
7946 // zcmusic_stop(zcmixer->newtrack);
7947 // zcmusic_unload_file(zcmixer->newtrack);
7948 //}
7949 3360 zc_stop_midi();
7950 3360 currmidi=-1;
7951 3360 }
7952
7953 void System()
7954 {
7955 mouse_down=gui_mouse_b();
7956 music_pause();
7957 pause_all_sfx();
7958 MenuOpen = true;
7959 enter_sys_pal();
7960 // FONT *oldfont=font;
7961 // font=tfont;
7962
7963 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7964 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7965
7966 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7967 #if DEVLEVEL > 1
7968 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7969 #endif
7970 game_menu[3].flags =
7971 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7972 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7973 clear_keybuf();
7974
7975 DIALOG_PLAYER *p;
7976
7977 clear_bitmap(menu_bmp);
7978 oldscreen = screen;
7979 screen = menu_bmp;
7980
7981 p = init_dialog(system_dlg,-1);
7982
7983 // drop the menu on startup if menu button pressed
7984 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7985 simulate_keypress(KEY_G << 8);
7986
7987 do
7988 {
7989 if(close_button_quit)
7990 {
7991 close_button_quit = false;
7992 f_Quit(qEXIT);
7993 if(Quit) break;
7994 }
7995 rest(17);
7996
7997 if(mouse_down && !gui_mouse_b())
7998 mouse_down=0;
7999
8000 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8001 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8002 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8003
8004 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8005 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8006 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8007 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8008 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8009 settings_menu[10].flags = NESquit?D_SELECTED:0;
8010 settings_menu[11].flags = volkeys?D_SELECTED:0;
8011
8012 window_menu[0].flags = DragAspect?D_SELECTED:0;
8013 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8014 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8015 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8016 window_menu[4].flags = stretchGame?D_SELECTED:0;
8017
8018 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8019 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
8020
8021 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8022 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8023 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8024
8025 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8026 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8027 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8028
8029 bool nocheat = (replay_is_replaying() || !Playing
8030 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8031 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8032 cheat_menu[0].flags = 0;
8033 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
8034 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8035 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8036 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8037 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8038 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8039 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8040 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8041 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8042
8043 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8044 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8045 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8046 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8047 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8048 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8049 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8050 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8051 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8052 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8053 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8054 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8055 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8056 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8057 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8058
8059 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8060 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8061
8062 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8063 (char *)"Disable recording new saves" :
8064 (char *)"Enable recording new saves";
8065 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8066 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8067 (char *)"Stop recording" :
8068 (char *)"Stop replaying";
8069 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8070 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8071 (char *)"Disable snapshot all frames" :
8072 (char *)"Enable snapshot all frames";
8073
8074 reset_snapshot_format_menu();
8075 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8076
8077 if(debug_enabled)
8078 {
8079 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8080 }
8081
8082 if(gui_mouse_b() && !mouse_down)
8083 break;
8084
8085 // press menu to drop the menu
8086 if(rMbtn())
8087 simulate_keypress(KEY_G << 8);
8088
8089 if(input_idle(true) > after_time())
8090 // run Screeen Saver
8091 {
8092 // Screen saver enabled for now.
8093 clear_keybuf();
8094 Matrix(ss_speed, ss_density, 0);
8095 system_pal(true);
8096 sys_mouse();
8097 broadcast_dialog_message(MSG_DRAW, 0);
8098 }
8099
8100 update_hw_screen();
8101 }
8102 while(update_dialog(p));
8103
8104 screen = oldscreen;
8105
8106 // font=oldfont;
8107 mouse_down=gui_mouse_b();
8108 shutdown_dialog(p);
8109 MenuOpen = false;
8110 if(Quit)
8111 {
8112 kill_sfx();
8113 music_stop();
8114 update_hw_screen();
8115 }
8116 else
8117 {
8118 music_resume();
8119 resume_all_sfx();
8120
8121 if(rc)
8122 ringcolor(false);
8123 }
8124 exit_sys_pal();
8125
8126 eat_buttons();
8127
8128 rc=false;
8129 clear_keybuf();
8130 // text_mode(0);
8131 }
8132
8133 116 void fix_dialogs()
8134 {
8135 116 jwin_center_dialog(about_dlg);
8136 116 jwin_center_dialog(gamepad_dlg);
8137 116 jwin_center_dialog(credits_dlg);
8138 116 jwin_center_dialog(gamemode_dlg);
8139 116 jwin_center_dialog(getnum_dlg);
8140 116 jwin_center_dialog(goto_dlg);
8141 116 jwin_center_dialog(keyboard_control_dlg);
8142 116 jwin_center_dialog(midi_dlg);
8143 116 jwin_center_dialog(quest_dlg);
8144 116 jwin_center_dialog(scrsaver_dlg);
8145 116 jwin_center_dialog(sound_dlg);
8146 116 jwin_center_dialog(triforce_dlg);
8147
8148 // digi_dp[1] += scrx;
8149 // digi_dp[2] += scry;
8150 // midi_dp[1] += scrx;
8151 // midi_dp[2] += scry;
8152 // pan_dp[1] += scrx;
8153 // pan_dp[2] += scry;
8154 // emus_dp[1] += scrx;
8155 // emus_dp[2] += scry;
8156 // buf_dp[1] += scrx;
8157 // buf_dp[2] += scry;
8158 // sfx_dp[1] += scrx;
8159 // sfx_dp[2] += scry;
8160 116 }
8161
8162 /*****************************/
8163 /**** Custom Sound System ****/
8164 /*****************************/
8165
8166 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8167 {
8168
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8169 }
8170
8171 // Run an NSF, or a MIDI if the NSF is missing somehow.
8172 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8173 {
8174 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8175
8176 // Found it
8177
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8178 {
8179 70 newzcmusic->fadevolume = 10000;
8180 70 newzcmusic->fadeoutframes = fadeoutframes;
8181
8182 70 zcmixer->newtrack = newzcmusic;
8183
8184 70 zcmusic_stop(zcmusic);
8185 70 zcmusic_unload_file(zcmusic);
8186 70 zc_stop_midi();
8187
8188 70 zcmusic=newzcmusic;
8189 70 int32_t temp_volume = emusic_volume;
8190
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8191 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8192 70 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8193 70 zcmusic_play(zcmusic, temp_volume);
8194
8195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8196 70 zcmusic_change_track(zcmusic,track);
8197
8198 70 return true;
8199 }
8200
8201 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8202
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8203 jukebox(midi);
8204
8205 79 return false;
8206 149 }
8207
8208 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8209 {
8210 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8211 // Found it
8212 if(newzcmusic!=NULL)
8213 {
8214 zcmusic_stop(zcmusic);
8215 zcmusic_unload_file(zcmusic);
8216 zc_stop_midi();
8217
8218 zcmusic=newzcmusic;
8219 zcmusic_play(zcmusic, emusic_volume);
8220
8221 if(track>0)
8222 zcmusic_change_track(zcmusic,track);
8223
8224 return true;
8225 }
8226
8227 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8228 else if(midi>-1000)
8229 jukebox(midi);
8230
8231 return false;
8232 }
8233
8234 int32_t get_zcmusicpos()
8235 {
8236 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8237 return debugtracething;
8238 return 0;
8239 }
8240
8241 void set_zcmusicpos(int32_t position)
8242 {
8243 zcmusic_set_curpos(zcmusic, position);
8244 }
8245
8246 void set_zcmusicspeed(int32_t speed)
8247 {
8248 zcmusic_set_speed(zcmusic, speed);
8249 }
8250
8251 int32_t get_zcmusiclen()
8252 {
8253 return zcmusic_get_length(zcmusic);
8254 }
8255
8256 void set_zcmusicloop(double start, double end)
8257 {
8258 zcmusic_set_loop(zcmusic, start, end);
8259 }
8260
8261 63871 void jukebox(int32_t index,int32_t loop)
8262 {
8263
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8264 63871 return;
8265
8266 music_stop();
8267
8268 if(index<0) index=MAXMIDIS-1;
8269
8270 if(index>=MAXMIDIS) index=0;
8271
8272 music_stop();
8273
8274 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8275 // stuck notes when a song stops. This fixes it.
8276 if(strcmp(midi_driver->name, "DIGMID")==0)
8277 zc_set_volume(0, 0);
8278
8279 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8280 zc_play_midi((MIDI*)tunes[index].data,loop);
8281
8282 if(tunes[index].start>0)
8283 zc_midi_seek(tunes[index].start);
8284
8285 midi_loop_start = tunes[index].loop_start;
8286 midi_loop_end = tunes[index].loop_end;
8287
8288 currmidi=index;
8289 master_volume(digi_volume, midi_volume);
8290 //midi_paused=false;
8291 63871 }
8292
8293 63871 void jukebox(int32_t index)
8294 {
8295
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8296
8297
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8298
8299 // do nothing if it's already playing
8300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8301 {
8302 return;
8303 }
8304
8305 63871 jukebox(index,tunes[index].loop);
8306 63871 }
8307
8308 16 void play_DmapMusic()
8309 {
8310
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8311 16 return;
8312
8313 static char tfile[2048];
8314 static int32_t ttrack=0;
8315 bool domidi=false;
8316
8317 int32_t fadeoutframes = 0;
8318 if (zcmusic != NULL)
8319 fadeoutframes = zcmusic->fadeoutframes;
8320
8321 if(DMaps[currdmap].tmusic[0]!=0)
8322 {
8323 if(zcmusic==NULL ||
8324 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8325 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8326 {
8327 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8328 {
8329 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8330 {
8331 if (zcmusic != NULL)
8332 {
8333 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8334 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8335 }
8336 }
8337 }
8338 else
8339 {
8340 if (zcmusic != NULL)
8341 {
8342 zcmusic_stop(zcmusic);
8343 zcmusic_unload_file(zcmusic);
8344 zcmusic = NULL;
8345 zcmixer->newtrack = NULL;
8346 }
8347
8348 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8349 zcmixer->newtrack = zcmusic;
8350
8351 if (zcmusic != NULL)
8352 {
8353 zc_stop_midi();
8354 strcpy(tfile, DMaps[currdmap].tmusic);
8355 zcmusic_play(zcmusic, emusic_volume);
8356 int32_t temptracks = 0;
8357 temptracks = zcmusic_get_tracks(zcmusic);
8358 temptracks = (temptracks < 2) ? 1 : temptracks;
8359 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8360 zcmusic_change_track(zcmusic, ttrack);
8361 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8362 }
8363 else
8364 {
8365 tfile[0] = 0;
8366 domidi = true;
8367 }
8368 }
8369 }
8370 }
8371 else
8372 {
8373 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8374 {
8375 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8376 }
8377 else
8378 {
8379 domidi = true;
8380 }
8381 }
8382
8383 if(domidi)
8384 {
8385 int32_t m=DMaps[currdmap].midi;
8386
8387 switch(m)
8388 {
8389 case 1:
8390 jukebox(ZC_MIDI_OVERWORLD);
8391 break;
8392
8393 case 2:
8394 jukebox(ZC_MIDI_DUNGEON);
8395 break;
8396
8397 case 3:
8398 jukebox(ZC_MIDI_LEVEL9);
8399 break;
8400
8401 default:
8402 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8403 jukebox(m+MIDIOFFSET_DMAP);
8404 else
8405 music_stop();
8406 }
8407 }
8408 16 }
8409
8410 15754 void playLevelMusic()
8411 {
8412
1/2
✓ Branch 0 taken 15754 times.
✗ Branch 1 not taken.
15754 if (is_headless())
8413 15754 return;
8414
8415 int32_t m=tmpscr->screen_midi;
8416
8417 switch(m)
8418 {
8419 case -2:
8420 music_stop();
8421 break;
8422
8423 case -1:
8424 play_DmapMusic();
8425 break;
8426
8427 case 1:
8428 jukebox(ZC_MIDI_OVERWORLD);
8429 break;
8430
8431 case 2:
8432 jukebox(ZC_MIDI_DUNGEON);
8433 break;
8434
8435 case 3:
8436 jukebox(ZC_MIDI_LEVEL9);
8437 break;
8438
8439 default:
8440 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8441 jukebox(m+MIDIOFFSET_MAPSCR);
8442 else
8443 music_stop();
8444 }
8445 15754 }
8446
8447 116 void master_volume(int32_t dv,int32_t mv)
8448 {
8449
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8450
8451
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8452
8453
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8454 116 int32_t temp_vol = midi_volume;
8455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8456 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8457 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8458 116 }
8459
8460 /*****************/
8461 /***** SFX *****/
8462 /*****************/
8463
8464 // array of voices, one for each sfx sample in the data file
8465 // 0+ = voice #
8466 // -1 = voice not allocated
8467 116 void Z_init_sound()
8468 {
8469
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8470 29696 sfx_voice[i]=-1;
8471
8472
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8473 812 tunes[i].data = (MIDI*)mididata[i].dat;
8474
8475
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8476 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8477
8478 116 master_volume(digi_volume,midi_volume);
8479 116 }
8480
8481 // returns number of voices currently allocated
8482 int32_t sfx_count()
8483 {
8484 int32_t c=0;
8485
8486 for(int32_t i=0; i<WAV_COUNT; i++)
8487 if(sfx_voice[i]!=-1)
8488 ++c;
8489
8490 return c;
8491 }
8492
8493 // clean up finished samples
8494 9217730 void sfx_cleanup()
8495 {
8496
2/2
✓ Branch 0 taken 2359738880 times.
✓ Branch 1 taken 9217730 times.
2368956610 for(int32_t i=0; i<WAV_COUNT; i++)
8497
3/4
✓ Branch 0 taken 619252 times.
✓ Branch 1 taken 2359119628 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619252 times.
2360358132 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8498 {
8499 619252 deallocate_voice(sfx_voice[i]);
8500 619252 sfx_voice[i]=-1;
8501 619252 }
8502 9217730 }
8503
8504 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8505 // if a voice is already allocated (and/or playing), then it just returns true
8506 // Returns true: voice is allocated
8507 // false: unsuccessful
8508 963669 bool sfx_init(int32_t index)
8509 {
8510 // check index
8511
3/4
✓ Branch 0 taken 721280 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721280 times.
963669 if(index<=0 || index>=WAV_COUNT)
8512 242389 return false;
8513
8514
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619269 times.
721280 if(sfx_voice[index]==-1)
8515 {
8516
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409393 times.
619269 if(sfxdat)
8517 {
8518
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8519 {
8520 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8521 209876 }
8522 else
8523 {
8524 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8525 }
8526 209876 }
8527 else
8528 {
8529 409393 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8530 }
8531
8532 619269 int32_t temp_volume = sfx_volume;
8533
1/2
✓ Branch 0 taken 619269 times.
✗ Branch 1 not taken.
619269 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8534 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8535 619269 voice_set_volume(sfx_voice[index], temp_volume);
8536 619269 }
8537
8538 721280 return sfx_voice[index] != -1;
8539 963669 }
8540
8541 int32_t sfx_get_default_freq(int32_t index)
8542 {
8543 if (sfxdat)
8544 {
8545 if (index < Z35)
8546 {
8547 return ((SAMPLE*)sfxdata[index].dat)->freq;
8548 }
8549 else
8550 {
8551 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8552 }
8553 }
8554 else
8555 {
8556 return customsfxdata[index].freq;
8557 }
8558 }
8559
8560 int32_t sfx_get_length(int32_t index)
8561 {
8562 if (sfxdat)
8563 {
8564 if (index < Z35)
8565 {
8566 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8567 }
8568 else
8569 {
8570 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8571 }
8572 }
8573 else
8574 {
8575 return int32_t(customsfxdata[index].len);
8576 }
8577 }
8578
8579 // plays an sfx sample
8580 963669 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8581 {
8582
2/2
✓ Branch 0 taken 721280 times.
✓ Branch 1 taken 242389 times.
963669 if(!sfx_init(index))
8583 242389 return;
8584
1/2
✓ Branch 0 taken 721280 times.
✗ Branch 1 not taken.
721280 if (!is_headless())
8585 {
8586 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8587 voice_set_pan(sfx_voice[index], pan);
8588
8589 // Only used by ZScript currently
8590 if (freq <= -1)
8591 {
8592 freq = sfx_get_default_freq(index);
8593 }
8594 voice_set_frequency(sfx_voice[index], freq);
8595
8596 // Only used by ZScript currently
8597 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8598 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8599 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8600 voice_set_volume(sfx_voice[index], temp_volume);
8601
8602 int32_t pos = voice_get_position(sfx_voice[index]);
8603
8604 if (restart) voice_set_position(sfx_voice[index], 0);
8605
8606 if (pos <= 0)
8607 voice_start(sfx_voice[index]);
8608 }
8609
8610
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721280 if (restart && replay_is_debug())
8611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8612 963669 }
8613
8614 // true if sfx is allocated
8615 67537 bool sfx_allocated(int32_t index)
8616 {
8617
3/4
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9408 times.
67537 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8618 }
8619
8620 // start it (in loop mode) if it's not already playing,
8621 // otherwise adjust it to play in loop mode -DD
8622 178223 void cont_sfx(int32_t index)
8623 {
8624
1/2
✓ Branch 0 taken 178223 times.
✗ Branch 1 not taken.
178223 if (is_headless())
8625 178223 return;
8626
8627 if(!sfx_init(index))
8628 {
8629 return;
8630 }
8631
8632 if(voice_get_position(sfx_voice[index])<=0)
8633 {
8634 voice_set_position(sfx_voice[index],0);
8635 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8636 voice_start(sfx_voice[index]);
8637 }
8638 else
8639 {
8640 adjust_sfx(index, 128, true);
8641 }
8642 178223 }
8643
8644 // adjust parameters while playing
8645 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8646 {
8647
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8648 4075 return;
8649
8650 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8651 voice_set_pan(sfx_voice[index],pan);
8652 4075 }
8653
8654 // pauses a voice
8655 1725 void pause_sfx(int32_t index)
8656 {
8657
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8658 voice_stop(sfx_voice[index]);
8659 1725 }
8660
8661 // resumes a voice
8662 747 void resume_sfx(int32_t index)
8663 {
8664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8665 747 return;
8666
8667 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8668 voice_start(sfx_voice[index]);
8669 747 }
8670
8671 // pauses all active voices
8672 452 void pause_all_sfx()
8673 {
8674
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8675
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8676 1 voice_stop(sfx_voice[i]);
8677 452 }
8678
8679 // resumes all paused voices
8680 438 void resume_all_sfx()
8681 {
8682
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8683
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8684 voice_start(sfx_voice[i]);
8685 438 }
8686
8687 // stops an sfx and deallocates the voice
8688 7334476 void stop_sfx(int32_t index)
8689 {
8690
3/4
✓ Branch 0 taken 6181367 times.
✓ Branch 1 taken 1153109 times.
✓ Branch 2 taken 6181367 times.
✗ Branch 3 not taken.
7334476 if(index<=0 || index>=WAV_COUNT)
8691 1153109 return;
8692
8693
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6181356 times.
6181367 if(sfx_voice[index]!=-1)
8694 {
8695 11 deallocate_voice(sfx_voice[index]);
8696 11 sfx_voice[index]=-1;
8697 11 }
8698 7334476 }
8699
8700 // Stops SFX played by Hero's item of the given family
8701 128638 void stop_item_sfx(int32_t family)
8702 {
8703 128638 int32_t id=current_item_id(family);
8704
8705
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8706 128083 return;
8707
8708 555 stop_sfx(itemsbuf[id].usesound);
8709 128638 }
8710
8711 3222 void kill_sfx()
8712 {
8713
2/2
✓ Branch 0 taken 824832 times.
✓ Branch 1 taken 3222 times.
828054 for(int32_t i=0; i<WAV_COUNT; i++)
8714
2/2
✓ Branch 0 taken 824826 times.
✓ Branch 1 taken 6 times.
824838 if(sfx_voice[i]!=-1)
8715 {
8716 6 deallocate_voice(sfx_voice[i]);
8717 6 sfx_voice[i]=-1;
8718 6 }
8719 3222 }
8720
8721 659811 int32_t pan(int32_t x)
8722 {
8723
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8724 {
8725 case 0:
8726 return 128;
8727
8728 case 1:
8729 659811 return vbound((x>>1)+68,0,255);
8730
8731 case 2:
8732 return vbound(((x*3)>>2)+36,0,255);
8733 }
8734
8735 return vbound(x,0,255);
8736 659811 }
8737
8738 /*******************************/
8739 /******* Input Handlers ********/
8740 /*******************************/
8741
8742 25094783 bool joybtn(int32_t b)
8743 {
8744
1/2
✓ Branch 0 taken 25094783 times.
✗ Branch 1 not taken.
25094783 if(b == 0)
8745 return false;
8746
1/2
✓ Branch 0 taken 25094783 times.
✗ Branch 1 not taken.
25094783 if (b-1 >= joy[joystick_index].num_buttons)
8747 25094783 return false;
8748
8749 return joy[joystick_index].button[b-1].b !=0;
8750 25094783 }
8751
8752 const char* joybtn_name(int32_t b)
8753 {
8754 if (b <= 0 || b > joy[joystick_index].num_buttons)
8755 return "";
8756
8757 return joy[joystick_index].button[b-1].name;
8758 }
8759
8760 int32_t next_press_key();
8761
8762 int32_t next_press_btn()
8763 {
8764 clear_keybuf();
8765 /*bool b[joy[joystick_index].num_buttons+1];
8766
8767 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8768 b[i]=joybtn(i);*/
8769
8770 //first, we need to wait until they're pressing no buttons
8771 for(;;)
8772 {
8773 if(keypressed())
8774 {
8775 switch(readkey()>>8)
8776 {
8777 case KEY_ESC:
8778 return -1;
8779
8780 case KEY_SPACE:
8781 return 0;
8782 }
8783 }
8784
8785 poll_joystick();
8786 bool done = true;
8787
8788 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8789 {
8790 if(joybtn(i)) done = false;
8791 }
8792
8793 if(done) break;
8794 rest(1);
8795 }
8796
8797 //now, we need to wait for them to press any button
8798 for(;;)
8799 {
8800 if(keypressed())
8801 {
8802 switch(readkey()>>8)
8803 {
8804 case KEY_ESC:
8805 return -1;
8806
8807 case KEY_SPACE:
8808 return 0;
8809 }
8810 }
8811
8812 poll_joystick();
8813
8814 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8815 {
8816 if(joybtn(i)) return i;
8817 }
8818 rest(1);
8819 }
8820 }
8821
8822 1204215 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8823 {
8824
2/2
✓ Branch 0 taken 1199872 times.
✓ Branch 1 taken 4343 times.
1204215 bool ret = btn && !flag;
8825 1204215 flag = rawbtn;
8826
8827 1204215 return ret;
8828 }
8829 190793632 static bool rButton(bool &btn, bool &flag)
8830 {
8831
2/2
✓ Branch 0 taken 183949617 times.
✓ Branch 1 taken 6844015 times.
190793632 bool ret = btn && !flag;
8832 190793632 flag = btn;
8833
8834 190793632 return ret;
8835 }
8836 2888985 static bool rButtonPeek(bool btn, bool flag)
8837 {
8838
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8839 {
8840 2685887 return false;
8841 }
8842
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8843 {
8844 17939 return true;
8845 }
8846
8847 185159 return false;
8848 2888985 }
8849
8850 // Updated only by keyboard/gamepad.
8851 // If in replay mode, this is set directly by the replay system.
8852 // This should never be read from directly - use control_state instead.
8853 bool raw_control_state[ZC_CONTROL_STATES];
8854
8855 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8856 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8857 // lasts until the next call to load_control_state.
8858 bool control_state[ZC_CONTROL_STATES];
8859 bool disable_control[ZC_CONTROL_STATES];
8860 bool drunk_toggle_state[11];
8861 bool disabledKeys[127];
8862 bool KeyInput[127];
8863 bool KeyPress[127];
8864
8865 bool key_current_frame[127];
8866 bool key_previous_frame[127];
8867
8868 static bool key_system[127];
8869 static bool key_system_previous[127];
8870 static bool key_system_press[127];
8871
8872 bool button_press[ZC_CONTROL_STATES];
8873 bool button_hold[ZC_CONTROL_STATES];
8874
8875 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8876 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8877 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8878 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8879 #define STICK_PRECISION 56 //define your own sensitivity
8880
8881 7800505 void load_control_state()
8882 {
8883 7800505 load_control_called_this_frame = true;
8884
8885
2/2
✓ Branch 0 taken 4832992 times.
✓ Branch 1 taken 2967513 times.
7800505 if (replay_version_check(8, 11))
8886 {
8887
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8888 53415234 down_control_states[i] = raw_control_state[i];
8889 2967513 }
8890
8891
1/2
✓ Branch 0 taken 7800505 times.
✗ Branch 1 not taken.
7800505 if (!replay_is_replaying())
8892 {
8893 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8894 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8895 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8896 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8897 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8898 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8899 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8900 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8901 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8902 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8903 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8904 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8905 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8906 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8907
8908 if(num_joysticks != 0)
8909 {
8910 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8911 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8912 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8913 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8914 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8915 }
8916 else
8917 {
8918 raw_control_state[14] = false;
8919 raw_control_state[15] = false;
8920 raw_control_state[16] = false;
8921 raw_control_state[17] = false;
8922 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8923 }
8924 }
8925
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7800502 times.
7800505 if (replay_is_active())
8926 {
8927
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785287 times.
7800502 if (replay_get_version() < 3)
8928 1015215 replay_poll();
8929
3/4
✓ Branch 0 taken 6785287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5023912 times.
✓ Branch 3 taken 1761375 times.
6785287 else if (replay_is_replaying() && replay_get_version() < 6)
8930 1761375 replay_peek_input();
8931
3/4
✓ Branch 0 taken 5023912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056399 times.
✓ Branch 3 taken 2967513 times.
5023912 else if (replay_is_replaying() && replay_version_check(8, 11))
8932 2967513 replay_peek_input();
8933
2/2
✓ Branch 0 taken 6696212 times.
✓ Branch 1 taken 1104290 times.
7800502 if (replay_get_version() == 8)
8934 1104290 update_keys();
8935 7800502 }
8936
8937 // Some test replay files were made before a serious input bug was fixed, so instead
8938 // of re-doing them or tossing them out, just check for that zplay version.
8939
3/4
✓ Branch 0 taken 7800499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7678599 times.
7800505 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8940
2/2
✓ Branch 0 taken 140408982 times.
✓ Branch 1 taken 7800499 times.
148209481 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8941 {
8942 140408982 control_state[i] = raw_control_state[i];
8943
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90921672 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140408982 if (botched_input && !control_state[i])
8944 47077142 down_control_states[i] = false;
8945 140408982 }
8946 7800499 bool did_bad_cutscene_btn = false;
8947
2/2
✓ Branch 0 taken 7800499 times.
✓ Branch 1 taken 140408982 times.
148209481 for(int q = 0; q < 18; ++q)
8948
3/4
✓ Branch 0 taken 6463843 times.
✓ Branch 1 taken 133945139 times.
✓ Branch 2 taken 6463843 times.
✗ Branch 3 not taken.
140408982 if(control_state[q] && !active_cutscene.can_button(q))
8949 {
8950 control_state[q] = false;
8951 did_bad_cutscene_btn = true;
8952 }
8953
1/2
✓ Branch 0 taken 7800499 times.
✗ Branch 1 not taken.
7800499 if(did_bad_cutscene_btn)
8954 active_cutscene.error();
8955
8956 7800499 button_press[0]=rButton(control_state[0],button_hold[0]);
8957 7800499 button_press[1]=rButton(control_state[1],button_hold[1]);
8958 7800499 button_press[2]=rButton(control_state[2],button_hold[2]);
8959 7800499 button_press[3]=rButton(control_state[3],button_hold[3]);
8960 7800499 button_press[4]=rButton(control_state[4],button_hold[4]);
8961 7800499 button_press[5]=rButton(control_state[5],button_hold[5]);
8962 7800499 button_press[6]=rButton(control_state[6],button_hold[6]);
8963 7800499 button_press[7]=rButton(control_state[7],button_hold[7]);
8964 7800499 button_press[8]=rButton(control_state[8],button_hold[8]);
8965 7800499 button_press[9]=rButton(control_state[9],button_hold[9]);
8966 7800499 button_press[10]=rButton(control_state[10],button_hold[10]);
8967 7800499 button_press[11]=rButton(control_state[11],button_hold[11]);
8968 7800499 button_press[12]=rButton(control_state[12],button_hold[12]);
8969 7800499 button_press[13]=rButton(control_state[13],button_hold[13]);
8970 7800499 button_press[14]=rButton(control_state[14],button_hold[14]);
8971 7800499 button_press[15]=rButton(control_state[15],button_hold[15]);
8972 7800499 button_press[16]=rButton(control_state[16],button_hold[16]);
8973 7800499 button_press[17]=rButton(control_state[17],button_hold[17]);
8974 7800499 }
8975
8976 // Returns true if any game key is pressed. This is needed because keypressed()
8977 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8978 40249762 bool zc_key_pressed()
8979 //may also need to use zc_getrawkey
8980 {
8981
7/10
✓ Branch 0 taken 32597432 times.
✓ Branch 1 taken 7652330 times.
✓ Branch 2 taken 7652330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396032 times.
✓ Branch 7 taken 6396032 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461864 times.
42711626 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8982
4/6
✓ Branch 0 taken 6396032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4844148 times.
✓ Branch 5 taken 4844148 times.
6396032 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8983
4/6
✓ Branch 0 taken 4844148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4844148 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143271 times.
✓ Branch 5 taken 3143271 times.
4844148 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8984
4/6
✓ Branch 0 taken 3143271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143271 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732337 times.
✓ Branch 5 taken 2732337 times.
3143271 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8985
1/2
✓ Branch 0 taken 2732337 times.
✗ Branch 1 not taken.
2732337 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8986
3/4
✓ Branch 0 taken 2612930 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612930 times.
✗ Branch 3 not taken.
2732337 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8987
3/4
✓ Branch 0 taken 2494027 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2494027 times.
✗ Branch 3 not taken.
2612930 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8988
3/4
✓ Branch 0 taken 2478882 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478882 times.
✗ Branch 3 not taken.
2494027 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8989
3/4
✓ Branch 0 taken 2465383 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465383 times.
✗ Branch 3 not taken.
2478882 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8990
3/4
✓ Branch 0 taken 2462889 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462889 times.
✗ Branch 3 not taken.
2465383 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8991
3/4
✓ Branch 0 taken 2462699 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462699 times.
✗ Branch 3 not taken.
2462889 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8992
3/4
✓ Branch 0 taken 2461889 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461889 times.
✗ Branch 3 not taken.
2462699 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8993
3/4
✓ Branch 0 taken 2461883 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461883 times.
✗ Branch 3 not taken.
2461889 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8994
2/2
✓ Branch 0 taken 2461864 times.
✓ Branch 1 taken 19 times.
2461883 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8995 72019474 return true;
8996
8997 2461864 return false;
8998 9286474 }
8999
9000 150323461 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9001 {
9002 150323461 bool ret = false, drunkstate = false, rawret = false;;
9003 150323461 bool* flag = &down_control_states[btn];
9004
2/7
✓ Branch 0 taken 141027650 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9295811 times.
150323461 switch(btn)
9005 {
9006 case btnF12:
9007 ret = zc_getkey(KEY_F12, ignoreDisable);
9008 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9009 eatEntirely = false;
9010 break;
9011 case btnF11:
9012 ret = zc_getkey(KEY_F11, ignoreDisable);
9013 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9014 eatEntirely = false;
9015 break;
9016 case btnF5:
9017 ret = zc_getkey(KEY_F5, ignoreDisable);
9018 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9019 eatEntirely = false;
9020 break;
9021 case btnQ:
9022 ret = zc_getkey(KEY_Q, ignoreDisable);
9023 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9024 eatEntirely = false;
9025 break;
9026 case btnI:
9027 ret = zc_getkey(KEY_I, ignoreDisable);
9028 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9029 eatEntirely = false;
9030 break;
9031 case btnM:
9032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9295811 times.
9295811 if(FFCore.kb_typing_mode) return false;
9033 9295811 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9034 9295811 eatEntirely = false;
9035 9295811 break;
9036 default: //control_state[] index
9037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141027650 times.
141027650 if(FFCore.kb_typing_mode) return false;
9038
5/6
✓ Branch 0 taken 140227871 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2227634 times.
✓ Branch 3 taken 138000237 times.
✓ Branch 4 taken 2227634 times.
✗ Branch 5 not taken.
141027650 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9039
2/2
✓ Branch 0 taken 8035707 times.
✓ Branch 1 taken 132991943 times.
141027650 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9040
4/4
✓ Branch 0 taken 126860784 times.
✓ Branch 1 taken 14166866 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14163862 times.
155194516 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9041 141027650 rawret = raw_control_state[btn];
9042 141027650 }
9043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150323461 times.
150323461 assert(flag);
9044
2/2
✓ Branch 0 taken 95845611 times.
✓ Branch 1 taken 54477850 times.
150323461 if(press)
9045 {
9046
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51588865 times.
54477850 if(peek)
9047 2888985 ret = rButtonPeek(ret, *flag);
9048
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1204215 times.
51588865 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9049 1204215 else ret = rButton(ret, *flag, rawret);
9050 54477850 }
9051
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150323461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150323461 if(eatEntirely && ret) control_state[btn] = false;
9052
3/4
✓ Branch 0 taken 112365312 times.
✓ Branch 1 taken 37958149 times.
✓ Branch 2 taken 112365312 times.
✗ Branch 3 not taken.
150323461 if(drunk && drunkstate) ret = !ret;
9053 150323461 return ret;
9054 150323461 }
9055
9056 7464560 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9057 {
9058 7464560 byte ret = 0;
9059
2/2
✓ Branch 0 taken 5485240 times.
✓ Branch 1 taken 1979320 times.
7464560 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9060
2/2
✓ Branch 0 taken 7333746 times.
✓ Branch 1 taken 130814 times.
7464560 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9061
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9062
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9063
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9064
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9065
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9066
2/2
✓ Branch 0 taken 7333871 times.
✓ Branch 1 taken 130689 times.
7464560 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9067 7464560 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9068 }
9069
9070 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9071 {
9072 1114 return intbtn&vals;
9073 }
9074
9075 1767676 bool Up()
9076 {
9077 1767676 return getInput(btnUp);
9078 }
9079 147173 bool Down()
9080 {
9081 147173 return getInput(btnDown);
9082 }
9083 257610 bool Left()
9084 {
9085 257610 return getInput(btnLeft);
9086 }
9087 286812 bool Right()
9088 {
9089 286812 return getInput(btnRight);
9090 }
9091 164908 bool cAbtn()
9092 {
9093 164908 return getInput(btnA);
9094 }
9095 1411891 bool cBbtn()
9096 {
9097 1411891 return getInput(btnB);
9098 }
9099 bool cSbtn()
9100 {
9101 return getInput(btnS);
9102 }
9103 68744 bool cLbtn()
9104 {
9105 68744 return getInput(btnL);
9106 }
9107 68744 bool cRbtn()
9108 {
9109 68744 return getInput(btnR);
9110 }
9111 bool cPbtn()
9112 {
9113 return getInput(btnP);
9114 }
9115 bool cEx1btn()
9116 {
9117 return getInput(btnEx1);
9118 }
9119 bool cEx2btn()
9120 {
9121 return getInput(btnEx2);
9122 }
9123 bool cEx3btn()
9124 {
9125 return getInput(btnEx3);
9126 }
9127 bool cEx4btn()
9128 {
9129 return getInput(btnEx4);
9130 }
9131 bool AxisUp()
9132 {
9133 return getInput(btnAxisUp);
9134 }
9135 bool AxisDown()
9136 {
9137 return getInput(btnAxisDown);
9138 }
9139 bool AxisLeft()
9140 {
9141 return getInput(btnAxisLeft);
9142 }
9143 bool AxisRight()
9144 {
9145 return getInput(btnAxisRight);
9146 }
9147
9148 bool cMbtn()
9149 {
9150 return getInput(btnM);
9151 }
9152 bool cF12()
9153 {
9154 return getInput(btnF12);
9155 }
9156 bool cF11()
9157 {
9158 return getInput(btnF11);
9159 }
9160 bool cF5()
9161 {
9162 return getInput(btnF5);
9163 }
9164 bool cQ()
9165 {
9166 return getInput(btnQ);
9167 }
9168 bool cI()
9169 {
9170 return getInput(btnI);
9171 }
9172
9173 130270 bool rUp()
9174 {
9175 130270 return getInput(btnUp, true);
9176 }
9177 130174 bool rDown()
9178 {
9179 130174 return getInput(btnDown, true);
9180 }
9181 130122 bool rLeft()
9182 {
9183 130122 return getInput(btnLeft, true);
9184 }
9185 129657 bool rRight()
9186 {
9187 129657 return getInput(btnRight, true);
9188 }
9189 1296 bool rAbtn()
9190 {
9191 1296 return getInput(btnA, true);
9192 }
9193 1296 bool rBbtn()
9194 {
9195 1296 return getInput(btnB, true);
9196 }
9197 7396439 bool rSbtn()
9198 {
9199 7396439 return getInput(btnS, true);
9200 }
9201 9286474 bool rMbtn()
9202 {
9203 9286474 return getInput(btnM, true);
9204 }
9205 129441 bool rLbtn()
9206 {
9207 129441 return getInput(btnL, true);
9208 }
9209 129436 bool rRbtn()
9210 {
9211 129436 return getInput(btnR, true);
9212 }
9213 7332903 bool rPbtn()
9214 {
9215 7332903 return getInput(btnP, true);
9216 }
9217 bool rEx1btn()
9218 {
9219 return getInput(btnEx1, true);
9220 }
9221 bool rEx2btn()
9222 {
9223 return getInput(btnEx2, true);
9224 }
9225 140087 bool rEx3btn()
9226 {
9227 140087 return getInput(btnEx3, true);
9228 }
9229 140087 bool rEx4btn()
9230 {
9231 140087 return getInput(btnEx4, true);
9232 }
9233 bool rAxisUp()
9234 {
9235 return getInput(btnAxisUp, true);
9236 }
9237 bool rAxisDown()
9238 {
9239 return getInput(btnAxisDown, true);
9240 }
9241 bool rAxisLeft()
9242 {
9243 return getInput(btnAxisLeft, true);
9244 }
9245 bool rAxisRight()
9246 {
9247 return getInput(btnAxisRight, true);
9248 }
9249
9250 bool rF11()
9251 {
9252 return getInput(btnF11, true);
9253 }
9254 bool rQ()
9255 {
9256 return getInput(btnQ, true);
9257 }
9258 bool rI()
9259 {
9260 return getInput(btnI, true);
9261 }
9262
9263 18225806 bool DrunkUp()
9264 {
9265 18225806 return getInput(btnUp, false, true);
9266 }
9267 16888776 bool DrunkDown()
9268 {
9269 16888776 return getInput(btnDown, false, true);
9270 }
9271 10288150 bool DrunkLeft()
9272 {
9273 10288150 return getInput(btnLeft, false, true);
9274 }
9275 8833832 bool DrunkRight()
9276 {
9277 8833832 return getInput(btnRight, false, true);
9278 }
9279 8035349 bool DrunkcAbtn()
9280 {
9281 8035349 return getInput(btnA, false, true);
9282 }
9283 8016797 bool DrunkcBbtn()
9284 {
9285 8016797 return getInput(btnB, false, true);
9286 }
9287 7263773 bool DrunkcEx1btn()
9288 {
9289 7263773 return getInput(btnEx1, false, true);
9290 }
9291 7263793 bool DrunkcEx2btn()
9292 {
9293 7263793 return getInput(btnEx2, false, true);
9294 }
9295 bool DrunkcSbtn()
9296 {
9297 return getInput(btnS, false, true);
9298 }
9299 bool DrunkcMbtn()
9300 {
9301 return getInput(btnM, false, true);
9302 }
9303 bool DrunkcLbtn()
9304 {
9305 return getInput(btnL, false, true);
9306 }
9307 bool DrunkcRbtn()
9308 {
9309 return getInput(btnR, false, true);
9310 }
9311 bool DrunkcPbtn()
9312 {
9313 return getInput(btnP, false, true);
9314 }
9315
9316 bool DrunkrUp()
9317 {
9318 return getInput(btnUp, true, true);
9319 }
9320 bool DrunkrDown()
9321 {
9322 return getInput(btnDown, true, true);
9323 }
9324 bool DrunkrLeft()
9325 {
9326 return getInput(btnLeft, true, true);
9327 }
9328 bool DrunkrRight()
9329 {
9330 return getInput(btnRight, true, true);
9331 }
9332 6081493 bool DrunkrAbtn()
9333 {
9334 6081493 return getInput(btnA, true, true);
9335 }
9336 6098325 bool DrunkrBbtn()
9337 {
9338 6098325 return getInput(btnB, true, true);
9339 }
9340 71669 bool DrunkrEx1btn()
9341 {
9342 71669 return getInput(btnEx1, true, true);
9343 }
9344 71662 bool DrunkrEx2btn()
9345 {
9346 71662 return getInput(btnEx2, true, true);
9347 }
9348 bool DrunkrEx3btn()
9349 {
9350 return getInput(btnEx3, true, true);
9351 }
9352 bool DrunkrEx4btn()
9353 {
9354 return getInput(btnEx4, true, true);
9355 }
9356 bool DrunkrSbtn()
9357 {
9358 return getInput(btnS, true, true);
9359 }
9360 bool DrunkrMbtn()
9361 {
9362 return getInput(btnM, true, true);
9363 }
9364 6688555 bool DrunkrLbtn()
9365 {
9366 6688555 return getInput(btnL, true, true);
9367 }
9368 6685080 bool DrunkrRbtn()
9369 {
9370 6685080 return getInput(btnR, true, true);
9371 }
9372 bool DrunkrPbtn()
9373 {
9374 return getInput(btnP, true, true);
9375 }
9376
9377 9337 void eat_buttons()
9378 {
9379 9337 getInput(btnA, true, false, true);
9380 9337 getInput(btnB, true, false, true);
9381 9337 getInput(btnS, true, false, true);
9382 9337 getInput(btnM, true, false, true);
9383 9337 getInput(btnL, true, false, true);
9384 9337 getInput(btnR, true, false, true);
9385 9337 getInput(btnP, true, false, true);
9386 9337 getInput(btnEx1, true, false, true);
9387 9337 getInput(btnEx2, true, false, true);
9388 9337 getInput(btnEx3, true, false, true);
9389 9337 getInput(btnEx4, true, false, true);
9390 9337 }
9391
9392 // Is true for the _first frame_ of a key press.
9393 // But! it is possible that a script manually sets the value of KeyPress,
9394 // in which case it will be restored to the "true" value based on `key_current_frame`
9395 // and `key_previous_frame` on the next frame.
9396 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9397 {
9398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9400 {
9401 case KEY_F7:
9402 case KEY_F8:
9403 case KEY_F9:
9404 return KeyPress[k];
9405
9406 default:
9407
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9408 }
9409 14 }
9410
9411 // Is true for _every frame_ a key is held down.
9412 // But! it is possible that a script manually sets the value of KeyInput,
9413 // in which case it will be restored to the "true" value based on `key_current_frame`
9414 // on the next frame.
9415 bool zc_getkey(int32_t k, bool ignoreDisable)
9416 {
9417 if(ignoreDisable) return KeyInput[k];
9418 switch(k)
9419 {
9420 case KEY_F7:
9421 case KEY_F8:
9422 case KEY_F9:
9423 return KeyInput[k];
9424
9425 default:
9426 return KeyInput[k] && !disabledKeys[k];
9427 }
9428 }
9429
9430 // Reads (and then clears) the current frame key state directly.
9431 // Scripts can also modify `key_current_frame`.
9432 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9433 {
9434
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9435 {
9436 2 _key[k]=key[k]=key_current_frame[k]=0;
9437 2 return true;
9438 }
9439 301 _key[k]=key[k]=key_current_frame[k]=0;
9440 301 return false;
9441 303 }
9442
9443 // Reads the current frame key state directly.
9444 // Scripts can also modify `key_current_frame`.
9445 63251288 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9446 {
9447
2/2
✓ Branch 0 taken 53964786 times.
✓ Branch 1 taken 9286502 times.
63251288 if(ignoreDisable) return key_current_frame[k];
9448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286502 times.
9286502 switch(k)
9449 {
9450 case KEY_F7:
9451 case KEY_F8:
9452 case KEY_F9:
9453 return key_current_frame[k];
9454
9455 default:
9456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286502 times.
9286502 return key_current_frame[k] && !disabledKeys[k];
9457 }
9458 63251288 }
9459
9460 // Only used for a handful of keys, like tilde and Function keys.
9461 // This state is never read within the game.
9462 // It exists so that all keyboard input still functions during replay,
9463 // without inadvertently doing things like toggling throttling if the player
9464 // presses ~
9465 9286474 bool zc_get_system_key(int32_t k)
9466 {
9467 9286474 return key_system[k];
9468 }
9469
9470 // True for the _first_ frame of a key press.
9471 83578266 bool zc_read_system_key(int32_t k)
9472 {
9473 83578266 return key_system_press[k];
9474 }
9475
9476 1179382198 bool is_system_key(int32_t k)
9477 {
9478
2/2
✓ Branch 0 taken 1095803932 times.
✓ Branch 1 taken 83578266 times.
1179382198 switch (k)
9479 {
9480 case KEY_BACKQUOTE:
9481 case KEY_CLOSEBRACE:
9482 case KEY_END:
9483 case KEY_HOME:
9484 case KEY_OPENBRACE:
9485 case KEY_PGDN:
9486 case KEY_PGUP:
9487 case KEY_TAB:
9488 case KEY_TILDE:
9489 83578266 return true;
9490 }
9491 1095803932 return is_Fkey(k);
9492 1179382198 }
9493
9494 9286474 void update_system_keys()
9495 {
9496
2/2
✓ Branch 0 taken 1179382198 times.
✓ Branch 1 taken 9286474 times.
1188668672 for (int32_t q = 0; q < 127; ++q)
9497 {
9498
2/2
✓ Branch 0 taken 195015954 times.
✓ Branch 1 taken 984366244 times.
1179382198 if (!is_system_key(q))
9499 984366244 continue;
9500
9501 195015954 key_system[q] = key[q];
9502
1/2
✓ Branch 0 taken 195015954 times.
✗ Branch 1 not taken.
195015954 key_system_press[q] = key_system[q] && !key_system_previous[q];
9503 195015954 key_system_previous[q] = key_system[q];
9504 195015954 }
9505 9286474 }
9506
9507 10390764 void update_keys()
9508 {
9509
2/2
✓ Branch 0 taken 1319627028 times.
✓ Branch 1 taken 10390764 times.
1330017792 for (int32_t q = 0; q < 127; ++q)
9510 {
9511 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9512
1/2
✓ Branch 0 taken 1319627028 times.
✗ Branch 1 not taken.
1319627028 if (!replay_is_replaying())
9513 key_current_frame[q] = key[q];
9514
9515
2/2
✓ Branch 0 taken 1309839657 times.
✓ Branch 1 taken 9787371 times.
1319627028 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9516 1319627028 KeyInput[q] = key_current_frame[q];
9517 1319627028 key_previous_frame[q] = key_current_frame[q];
9518 1319627028 }
9519 10390764 }
9520
9521 bool zc_disablekey(int32_t k, bool val)
9522 {
9523 switch(k)
9524 {
9525 case KEY_F7:
9526 case KEY_F8:
9527 case KEY_F9:
9528 return false;
9529
9530 default:
9531 disabledKeys[k] = val;
9532 return true;
9533 }
9534 }
9535
9536 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9537 {
9538 timer=timer;
9539 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9540 }
9541